@explorer02/cfm-survey-sdk 0.4.0 → 0.4.2
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.
- package/dist/cli/index.js +69 -65
- package/dist/cli/index.mjs +69 -65
- package/package.json +1 -1
- package/templates/docs/templates/CsatMatrixScale.tsx +102 -29
- package/templates/docs/templates/Footer.tsx +3 -2
- package/templates/docs/templates/RatingScale.tsx +4 -20
- package/templates/docs/templates/labelStyles.ts +44 -0
- package/templates/docs/templates/surveyUiIcons.tsx +6 -1
- package/templates/docs/templates/uiConfig.ts +23 -8
- package/templates/preview-harness/preview-bridge.inline.js +12 -0
- package/templates/preview-harness/preview-google-fonts.html +6 -0
- package/templates/preview-harness/previewPages.js +3 -2
- package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +82 -18
- package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +1 -1
- package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +3 -3
- package/templates/preview-harness/vite-app/src/fixtures/questions.ts +6 -9
- package/templates/preview-harness/vite-app/src/globals.css +4 -3
- package/templates/preview-harness/vite-app/src/mergePreviewQuestion.ts +67 -7
- package/templates/preview-harness/vite-app/src/preview-live-overrides.css +9 -0
- package/templates/previewBridge.ts +13 -0
- package/templates/survey-theme.css +13 -0
- package/templates/wizard-dist/assets/{PreviewMock-BlOAvUCN.js → PreviewMock-B2SDZ408.js} +1 -1
- package/templates/wizard-dist/assets/TypePanel-COi_YFKb.js +1 -0
- package/templates/wizard-dist/assets/index-BbqXvrx7.js +34 -0
- package/templates/wizard-dist/index.html +1 -1
- package/templates/wizard-dist/assets/TypePanel-DcbMaw1b.js +0 -1
- package/templates/wizard-dist/assets/index-2Bi_7Fdh.js +0 -34
package/dist/cli/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var dt=Object.create;var He=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var q=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ne=(e,o)=>{for(var t in o)He(e,t,{get:o[t],enumerable:!0})},mt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of ut(o))!gt.call(e,r)&&r!==t&&He(e,r,{get:()=>o[r],enumerable:!(n=ft(o,r))||n.enumerable});return e};var A=(e,o,t)=>(t=e!=null?dt(pt(e)):{},mt(o||!e||!e.__esModule?He(t,"default",{value:e,enumerable:!0}):t,e));var l,W=q(()=>{"use strict";l={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"}});var G,Te=q(()=>{"use strict";G=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function wt(e){let o={};for(let t of e)yo[t]&&(o[t]={...yo[t]});return o}function bt(e=[],o){return{version:"1.0",instanceId:o,surveyTypes:e,global:{surveyTitle:"Customer Feedback Survey",companyName:"Sprinklr",browserTabTitle:"Customer Feedback Survey",thankYouMessage:"Thank you for your valuable feedback!",logo:{fileName:null,url:null},header:{height:120,logoBoxWidth:120,logoBoxHeight:120,logoPadding:10,logoPlacement:"left",showCompanyName:!0,companyNamePlacement:"left",companyNameFontSize:18,companyNameFontWeight:600,companyNameColor:"#1A1F36",backgroundColor:"#FFFFFF",shadowEnabled:!0,borderBottomColor:"#E5E7EB",contentPaddingX:40},footer:{backgroundColor:"#262626",textColor:"#9CA3AF",linkColor:"#9CA3AF",linkHoverColor:"#FFFFFF",showLogo:!0,logoWidth:120,logoHeight:32,logoPlacement:"left",copyrightText:"\xA9 Company Name",layout:"row",paddingY:21,paddingX:40,links:[]},theme:{pageBackground:"#FFFFFF",cardBackground:"#FFFFFF",cardBorderColor:"#E5E7EB",cardPadding:24,cardShadowEnabled:!0,selectedBackground:"#E8F5FD",zebraRowColor:"rgba(249,250,251,0.8)",rowBandColor:"#F3F4F6",validationBorder:"#333333",validationBackground:"#D9D9D9",tooltipBackground:"#1F2937",progressTrackHeight:12,progressTrackColor:"#E5E7EB",progressFillColor:"#1A1F36",stickyChromePaddingTop:16,stickyChromePaddingBottom:20,languageSelectorBackground:"#FFFFFF",languageSelectorTextColor:"#2563EB",languageSelectorBorderColor:"#2563EB"},layout:{showHeader:!0,showFooter:!0,showProgressBar:!0,showLanguageSwitcher:!1,showNextButton:!0,showBackButton:!0,showQuestionNumbers:!0,showRequiredAsterisk:!0,width:"standard",borderStyle:"rounded",fontStyle:"modern"},buttons:{next:"Next",back:"Back",submit:"Submit"},colorScheme:{...L},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:wt(e),placeholders:{firstName:"Alex",lastName:"Customer",email:"alex@example.com"},customFields:{},debug:{enabled:!1,sampleAnswers:{}},deploy:{target:"aws",autoDeploy:!1}}}function ee(e,o){return{...e,...o??{}}}function ve(e){let o=(e.surveyTypes??[]).filter(c=>G.includes(c)),t=[...new Set([...o,...G])],n=bt(t,e.instanceId),r=e.global??{},i=n.global,s={...n.questionTypes};if(e.questionTypes)for(let[c,d]of Object.entries(e.questionTypes))s[c]={...s[c]??{},...d};return{...n,...e,configuredAt:void 0,surveyTypes:o.length?o:n.surveyTypes,global:{...i,...r,header:ee(i.header,r.header),footer:ee(i.footer,r.footer),theme:ee(i.theme,r.theme),layout:ee(i.layout,r.layout),buttons:ee(i.buttons,r.buttons),logo:ee(i.logo,r.logo),colorScheme:ee(i.colorScheme,r.colorScheme),typography:ee(i.typography,r.typography),motion:ee(i.motion,r.motion)},questionTypes:s,placeholders:{...n.placeholders,...e.placeholders??{}},customFields:{...n.customFields,...e.customFields??{}},debug:{enabled:e.debug?.enabled??n.debug?.enabled??!1,sampleAnswers:e.debug?.sampleAnswers??n.debug?.sampleAnswers},deploy:{...n.deploy,...e.deploy??{}}}}var L,yo,Ve=q(()=>{"use strict";Te();L={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},yo={MCQ:{cardStyle:"outlined",selectedAccent:L.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:L.secondary,hoverBorderColor:L.accent},TEXTFIELD:{inputRadius:8,focusRing:L.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:L.secondary,labelColor:L.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:L.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:L.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:L.primary,cellPadding:8,accentColor:L.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:L.accent,cellSize:40,tooltipBg:"#1F2937",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:L.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:L.primary,rowLabelWidth:180,unselectedStarOpacity:.5,graphicsTrackColor:"#E5E7EB",graphicsThumbColor:L.primary},SLIDER_MATRIX:{trackColor:L.accent,thumbColor:L.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:L.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:L.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:L.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:L.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});function Co(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let r=n[0].split(":")[0].trim(),i=n[1].trim();o[r]=i}return o}function E(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function So(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function xe(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function To(e){let o={global:{},questionTypes:{}},t=o.global,n={},r={},i={},s={},c={},d={},m={},g=o.questionTypes;if(e["--cfm-primary"]&&(n.primary=e["--cfm-primary"]),e["--cfm-secondary"]&&(n.secondary=e["--cfm-secondary"]),e["--cfm-accent"]&&(n.accent=e["--cfm-accent"]),e["--cfm-background"]&&(n.background=e["--cfm-background"]),e["--cfm-text"]&&(n.text=e["--cfm-text"]),e["--cfm-button-text"]&&(n.buttonText=e["--cfm-button-text"]),e["--cfm-max-width"]&&ho[e["--cfm-max-width"]]&&(c.width=ho[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&wo[e["--cfm-border-radius"]]&&(c.borderStyle=wo[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],bo[e["--cfm-font-family"]]&&(c.fontStyle=bo[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=xe(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let O=E(e["--cfm-motion-duration"]);O!==void 0&&(m.durationMs=O,m.enabled=O>0)}e["--cfm-header-height"]&&(r.height=E(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(r.logoBoxWidth=E(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(r.logoBoxHeight=E(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(r.logoPadding=E(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(r.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(r.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(r.companyNameFontSize=E(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(r.companyNameFontWeight=xe(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(r.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(r.contentPaddingX=E(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(i.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(i.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(i.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(i.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(i.logoWidth=E(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(i.logoHeight=E(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(i.paddingY=E(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(i.paddingX=E(e["--cfm-footer-padding-x"])),e["--cfm-background"]&&(s.pageBackground=e["--cfm-background"]),e["--cfm-card-bg"]&&(s.cardBackground=e["--cfm-card-bg"]),e["--cfm-card-border-color"]&&(s.cardBorderColor=e["--cfm-card-border-color"]),e["--cfm-card-padding"]&&(s.cardPadding=E(e["--cfm-card-padding"])),e["--cfm-card-shadow"]&&(s.cardShadowEnabled=e["--cfm-card-shadow"]!=="none"),e["--cfm-selected-bg"]&&(s.selectedBackground=e["--cfm-selected-bg"]),e["--cfm-zebra-row"]&&(s.zebraRowColor=e["--cfm-zebra-row"]),e["--cfm-row-band"]&&(s.rowBandColor=e["--cfm-row-band"]),e["--cfm-validation-border"]&&(s.validationBorder=e["--cfm-validation-border"]),e["--cfm-validation-bg"]&&(s.validationBackground=e["--cfm-validation-bg"]),e["--cfm-tooltip-bg"]&&(s.tooltipBackground=e["--cfm-tooltip-bg"]),e["--cfm-progress-height"]&&(s.progressTrackHeight=E(e["--cfm-progress-height"])),e["--cfm-progress-track"]&&(s.progressTrackColor=e["--cfm-progress-track"]),e["--cfm-progress-fill"]&&(s.progressFillColor=e["--cfm-progress-fill"]),e["--cfm-sticky-pt"]&&(s.stickyChromePaddingTop=E(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=E(e["--cfm-sticky-pb"]));let S={};e["--cfm-mcq-selected-accent"]&&(S.selectedAccent=e["--cfm-mcq-selected-accent"]),e["--cfm-mcq-border-radius"]&&(S.borderRadius=E(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(S.optionGap=E(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(S.cardPadding=E(e["--cfm-mcq-card-padding"])),e["--cfm-mcq-selected-bg"]&&(S.selectedBackground=e["--cfm-mcq-selected-bg"]),e["--cfm-mcq-hover-border"]&&(S.hoverBorderColor=e["--cfm-mcq-hover-border"]),Object.keys(S).length&&(g.MCQ=S);let x={};e["--cfm-input-radius"]&&(x.inputRadius=E(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(x.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(x.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(x.inputPadding=E(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=E(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(g.TEXTFIELD=x);let F={};e["--cfm-nps-selected-fill"]&&(F.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(F.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(F.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(F.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(F.cellSize=E(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(F.cellGap=E(e["--cfm-nps-cell-gap"])),Object.keys(F).length&&(g.NPS_SCALE=F);let k=E(e["--cfm-matrix-row-width"]),R={};k!==void 0&&(R.rowLabelWidth=k),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=So(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&(R.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&(R.cellPadding=E(e["--cfm-matrix-cell-padding"])),Object.keys(R).length&&(g.CFM_MATRIX=R);let p={...R};e["--cfm-csat-accent"]&&(p.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(p.emojiSize=E(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(p.unselectedOpacity=xe(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(p.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(p.cellSize=E(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(p.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(p).length>Object.keys(R).length||e["--cfm-csat-accent"])&&(g.CSAT_MATRIX=p);let h={};e["--cfm-star-color"]&&(h.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(h.badgeColor=e["--cfm-badge-color"]),k!==void 0&&(h.rowLabelWidth=k),e["--cfm-star-unselected-opacity"]&&(h.unselectedStarOpacity=xe(e["--cfm-star-unselected-opacity"])),Object.keys(h).length&&(g.RATING_MATRIX=h);let T={};e["--cfm-slider-track"]&&(T.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(T.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(T.tickColor=e["--cfm-slider-tick"]),k!==void 0&&(T.rowLabelWidth=k),e["--cfm-slider-row-band"]&&(T.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(T.tickBadgeSize=E(e["--cfm-slider-tick-size"])),Object.keys(T).length&&(g.SLIDER_MATRIX=T);let $={};e["--cfm-upload-accent"]&&($.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&($.dropzonePadding=E(e["--cfm-upload-padding"])),Object.keys($).length&&(g.FILE_UPLOAD=$);let b={};e["--cfm-media-max-width"]&&(b.mediaMaxWidth=So(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(b.mediaRadius=E(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(b.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(b.captionSize=E(e["--cfm-media-caption-size"])),Object.keys(b).length&&(g.TEXT_AND_MEDIA=b);let P={};e["--cfm-heatmap-pin"]&&(P.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(P.pinSize=E(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(P.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(P.overlayOpacity=xe(e["--cfm-heatmap-overlay-opacity"])),Object.keys(P).length&&(g.HEATMAP=P);let C={};return e["--cfm-rank-item-bg"]&&(C.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(C.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(C.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(C.itemPadding=E(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(C.itemGap=E(e["--cfm-rank-item-gap"])),Object.keys(C).length&&(g.RANK_ORDER=C),Object.keys(n).length&&(t.colorScheme=n),Object.keys(r).length&&(t.header=r),Object.keys(i).length&&(t.footer=i),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(m).length&&(t.motion=m),o}function ue(e){let o=[$e.join(e,"src","styles","survey-theme.css"),$e.join(e,"src","app","survey-theme.css"),$e.join(e,"src","styles","globals.css"),$e.join(e,"src","app","globals.css")];for(let t of o)if(De.existsSync(t)&&De.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var De,$e,ho,wo,bo,Le=q(()=>{"use strict";De=A(require("fs")),$e=A(require("path")),ho={"36rem":"narrow","48rem":"standard","64rem":"wide"},wo={"0px":"sharp","12px":"rounded","9999px":"pill"},bo={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});function Ct(e){for(let o of St){let t=xo.join(e,o);if(Me.existsSync(t))return t}return null}function Tt(e){let o=e.trim();if(!o||o.startsWith("http")||o.startsWith("data:"))return null;let t=o.split("?")[0];return t.startsWith("/")?t.slice(1):t}function $o(e){let o=Ct(e);if(!o)return null;let t=Me.readFileSync(o,"utf8"),n=t.match(/data-cfm-logo[\s\S]*?src=["']([^"']+)["']/i)??t.match(/src=["']([^"']+)["'][\s\S]*?data-cfm-logo/i);if(n){let s=Tt(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let r=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(r)return{mode:"text",label:r[1].trim()};let i=t.match(/data-cfm-company[^>]*>([^<]+)</i);return i&&!n?{mode:"text",label:i[1].trim()}:null}var Me,xo,St,Ro=q(()=>{"use strict";Me=A(require("fs")),xo=A(require("path")),St=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var Po={};Ne(Po,{logSeedSource:()=>Ge,resolveInitialConfig:()=>ge,writeResolvedUiConfig:()=>Qe});function Je(e){return e.filter(o=>G.includes(o))}function Ao(e){try{let o=JSON.parse(Q.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function Rt(e){let o={global:{}};if(!Q.existsSync(e))return o;let t=Q.readFileSync(e,"utf8"),n=new Set;for(let i of G)t.includes(i)&&n.add(i);n.size&&(o.surveyTypes=[...n]);let r=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(r){let i=r[1].trim(),s=i.match(/company[:\s]+([^,;]+)/i),c=i.match(/title[:\s]+([^,;]+)/i);if(s&&(o.global.companyName=s[1].trim()),c){let d=c[1].trim();o.global.surveyTitle=d,o.global.browserTabTitle=d}}return o}function Fo(e,o){let t=oe.join(e,o);if(!Q.existsSync(t))return null;let n=Q.readFileSync(t);if(n.length>xt)return{fileName:o,dataUrl:""};let r=oe.extname(o).toLowerCase(),i=$t[r]??"application/octet-stream";return{fileName:o,dataUrl:`data:${i};base64,${n.toString("base64")}`}}function Eo(e,o){if(!o)return null;if(o.url&&typeof o.url=="string")return{fileName:o.fileName??null,url:o.url};if(o.fileName){let t=Fo(e,o.fileName);if(t)return{fileName:t.fileName,url:t.dataUrl||null}}return o.fileName===null&&o.url===null?{fileName:null,url:null}:null}function ko(e,o){let t=e.global??{},n=o.global??{},r=e.questionTypes??{},i=o.questionTypes??{},s={...r};for(let[c,d]of Object.entries(i))s[c]={...s[c]??{},...d};return{...e,...o,surveyTypes:o.surveyTypes??e.surveyTypes,global:{...t,...n,header:{...t.header,...n.header},footer:{...t.footer,...n.footer},theme:{...t.theme,...n.theme},layout:{...t.layout,...n.layout},buttons:{...t.buttons,...n.buttons},logo:{...t.logo,...n.logo},colorScheme:{...t.colorScheme,...n.colorScheme},typography:{...t.typography,...n.typography},motion:{...t.motion,...n.motion}},questionTypes:s,placeholders:{...e.placeholders,...o.placeholders},customFields:{...e.customFields,...o.customFields},deploy:{...e.deploy,...o.deploy}}}function ge(e){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=oe.join(o,"survey-ui-config.json"),n=oe.join(o,"implementation_plan.md"),r=oe.join(o,"public"),i=Je(e.surveyTypes),s={},c="defaults",d=ue(o);if(d){let C=Q.readFileSync(d,"utf8"),O=Co(C);Object.keys(O).length>0&&(s=To(O),c="survey-theme.css")}let m=Rt(n);s=ko(s,m);let g=Ao(t);g&&(s=ko(s,g),c="survey-ui-config.json");let S=oe.join(o,"survey-ui-config.final.json"),x=Ao(S),F=!!g?.configuredAt,k=!!x?.configuredAt;if(x&&k&&!F){let C=Eo(r,x.global?.logo);C&&(s.global={...s.global??{},logo:{fileName:C.fileName,url:C.url}})}let R=Eo(r,s.global?.logo),p=$o(o),h=!!g?.configuredAt,T=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),$=p?.mode==="image"?p.fileName:null,b=!h&&T&&$!=null&&R?.fileName!==$;if(R&&!b)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(p?.mode==="image"){let C=Fo(r,p.fileName);s.global={...s.global??{},logo:{fileName:p.fileName,url:C?.dataUrl||null}}}else p?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??p.label});return s.surveyTypes=Je(s.surveyTypes??i),s.surveyTypes?.length||(s.surveyTypes=i),e.instanceId&&(s.instanceId=e.instanceId),{config:ve(s),source:c}}function Ge(e){console.log(e==="survey-ui-config.json"?`${pe.dim} Seeding wizard from survey-ui-config.json${pe.reset}`:e==="survey-theme.css"?`${pe.dim} Seeding wizard from survey-theme.css + defaults${pe.reset}`:`${pe.dim} Seeding wizard from SDK defaults${pe.reset}`)}function Qe(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??Je(G),{config:n}=ge({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),r=oe.join(o,"survey-ui-config.json");return Q.writeFileSync(r,JSON.stringify(n,null,2),"utf8"),r}var Q,oe,pe,xt,$t,Re=q(()=>{"use strict";Q=A(require("fs")),oe=A(require("path"));W();Ve();Le();Te();Ro();pe=l,xt=512e3,$t={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function w(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function a(e,o){return typeof e=="string"&&e.length?e:o}function Mt(){return{"--cfm-header-brand-gap":"16px","--cfm-header-padding-y":"12px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0","--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start"}}function Bt(){return{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":"start","--cfm-footer-links-col":"3","--cfm-footer-links-justify":"end","--cfm-footer-logo-copyright-gap":"12px"}}function Oe(e,o){o.numberLabelMode&&(e["--cfm-number-label-mode"]=a(o.numberLabelMode,"traffic")),o.monochromeNumberColor&&(e["--cfm-number-mono-color"]=a(o.monochromeNumberColor,"#9CA3AF"));let t=o.individualNumberColors;Array.isArray(t)&&t.forEach((n,r)=>{typeof n=="string"&&(e[`--cfm-number-color-${r}`]=n)})}function Bo(e,o){o.hintLabelColor&&(e["--cfm-hint-label-color"]=a(o.hintLabelColor,"#6B7280")),o.hintLabelBgColor&&(e["--cfm-hint-label-bg"]=a(o.hintLabelBgColor,"transparent"))}function oo(e,o,t){(t==="matrix"||t==="csat")&&(o.columnLabelColor&&(e["--cfm-matrix-column-label-color"]=a(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-matrix-column-label-bg"]=a(o.columnLabelBgColor,"transparent"))),t==="csat"&&(o.columnLabelColor&&(e["--cfm-csat-column-label-color"]=a(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-csat-column-label-bg"]=a(o.columnLabelBgColor,"transparent"))),t==="rating"&&(o.columnLabelColor&&(e["--cfm-rating-column-label-color"]=a(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-rating-column-label-bg"]=a(o.columnLabelBgColor,"transparent")))}function Ot(e,o){let t=a(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${w(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${w(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${w(o.optionPadding??o.cardPadding,12)}px`,e["--cfm-mcq-hover-border"]=a(o.hoverBorderColor,"#00B5AD"),e["--cfm-mcq-option-style"]=t,o.filledOptionBg&&(e["--cfm-mcq-filled-bg"]=a(o.filledOptionBg,"#F9FAFB"))}function Ut(e,o){e["--cfm-input-radius"]=`${w(o.inputRadius,8)}px`,e["--cfm-input-border"]=a(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${w(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${w(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=a(o.placeholderColor,"#9CA3AF")}function zt(e,o){e["--cfm-nps-cell-size"]=`${w(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${w(o.cellGap,4)}px`,e["--cfm-nps-button-style"]=a(o.buttonStyle,"numbered"),e["--cfm-nps-selected-fill"]=a(o.selectedFill,"#E8F5FD"),e["--cfm-nps-track-bar"]=a(o.trackBarColor,"#F2F2F2"),e["--cfm-nps-track-highlight"]=a(o.trackHighlightColor,"#FBE8F3"),Bo(e,o),Oe(e,o)}function qt(e,o){e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${w(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${w(o.cellPadding,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=a(o.carouselDotColor,"#2563EB")),oo(e,o,"matrix")}function Wt(e,o){e["--cfm-csat-emoji-size"]=`${w(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(w(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(w(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${w(o.cellSize,40)}px`,e["--cfm-csat-tooltip-bg"]=a(o.tooltipBg,"#1F2937"),e["--cfm-csat-accent"]=a(o.accentColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=a(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=a(o.graphicsThumbColor,e["--cfm-accent"]??"#00B5AD"),oo(e,o,"csat"),Oe(e,o)}function Xt(e,o){e["--cfm-star-color"]=a(o.starColor,"#F59E0B"),e["--cfm-badge-color"]=a(o.badgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-csat-emoji-size"]=`${w(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(w(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(w(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=a(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=a(o.graphicsThumbColor,e["--cfm-primary"]??"#1A1F36"),oo(e,o,"rating"),Oe(e,o)}function Ht(e,o){e["--cfm-slider-track"]=a(o.trackColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-slider-thumb"]=a(o.thumbColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-slider-tick"]=a(o.tickColor,"#9CA3AF"),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-row-band"]=a(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${w(o.tickBadgeSize,28)}px`,Bo(e,o),Oe(e,o)}function Vt(e,o){e["--cfm-upload-border-color"]=a(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${w(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=a(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=a(o.dropzoneStyle,"dashed")}function Jt(e,o){e["--cfm-media-max-width"]=`${w(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${w(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=a(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${w(o.captionSize,14)}px`}function Gt(e,o){e["--cfm-heatmap-pin"]=a(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${w(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=a(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(w(o.overlayOpacity,0))}function Qt(e,o){let t=X(o.drag)??o,n=X(o.dropdown)??t,r=a(n.itemHoverBg??t.itemHoverBg,"#F3F4F6");e["--cfm-rank-item-bg"]=a(t.itemBg??n.itemBg,"#F9FAFB"),e["--cfm-rank-dropdown-hover-bg"]=r,e["--cfm-rank-badge-bg"]=a(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-badge-text"]="#ffffff",e["--cfm-rank-badge"]=a(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-item-padding"]=`${w(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${w(t.itemGap,8)}px`,e["--cfm-rank-handle"]=a(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=a(n.selectBorderColor,"#E5E7EB")}function Ue(e){let o=X(e.global)??{},t=X(o.colorScheme)??{},n=X(o.header)??{},r=X(o.footer)??{},i=X(o.theme)??{},s=X(o.layout)??{},c=X(o.typography)??{},d=X(o.motion)??{},m=e.questionTypes??{},g=a(s.fontStyle,"modern"),S=Mo[g]??a(c.fontFamily,Mo.modern),x=a(s.width,"standard"),F=a(s.borderStyle,"rounded"),k=a(i.cellSelectedColor,a(t.accent,"#00B5AD")),R=a(i.focusRingColor,a(t.accent,"#00B5AD")),p=a(i.selectedBackground,a(t.secondary,"#E8F5FD")),h={"--cfm-primary":a(t.primary,"#1A1F36"),"--cfm-secondary":a(t.secondary,"#E8F5FD"),"--cfm-accent":a(t.accent,"#00B5AD"),"--cfm-background":a(i.pageBackground??t.background,"#FFFFFF"),"--cfm-text":a(t.text,"#1A1F36"),"--cfm-button-text":a(t.buttonText,"#FFFFFF"),"--cfm-max-width":Do[x]??Do.standard,"--cfm-border-radius":Lo[F]??Lo.rounded,"--cfm-font-family":S,"--cfm-heading-weight":String(w(c.headingWeight,700)),"--cfm-motion-duration":`${w(d.durationMs,200)}ms`,"--cfm-header-height":`${w(n.height,120)}px`,"--cfm-header-logo-width":`${w(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${w(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${w(n.logoPadding,10)}px`,"--cfm-header-show-company":n.showCompanyName===!1?"0":"1","--cfm-header-bg":a(n.backgroundColor,"#FFFFFF"),"--cfm-header-company-color":a(n.companyNameColor,a(t.text,"#1A1F36")),"--cfm-header-company-size":`${w(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(w(n.companyNameFontWeight,600)),"--cfm-header-border":a(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${w(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",...Mt(),"--cfm-footer-bg":a(r.backgroundColor,"#262626"),"--cfm-footer-text":a(r.textColor,"#9CA3AF"),"--cfm-footer-link":a(r.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":a(r.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${w(r.logoWidth,120)}px`,"--cfm-footer-logo-height":`${w(r.logoHeight,32)}px`,"--cfm-footer-padding-y":`${w(r.paddingY,24)}px`,"--cfm-footer-padding-x":`${w(r.paddingX,40)}px`,...Bt(),"--cfm-card-bg":a(i.cardBackground,"#FFFFFF"),"--cfm-card-border-color":a(i.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${w(i.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":i.cardShadowEnabled===!1?"none":`0 ${w(i.cardShadowOffsetY,1)}px ${w(i.cardShadowBlur,3)}px ${a(i.cardShadowColor,"rgba(0,0,0,0.1)")}`,"--cfm-selected-bg":p,"--cfm-mcq-selected-accent":R,"--cfm-mcq-selected-bg":p,"--cfm-matrix-selected":k,"--cfm-csat-ring-color":k,"--cfm-input-focus-ring":R,"--cfm-zebra-row":a(i.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":a(i.rowBandColor,"#F3F4F6"),"--cfm-validation-border":a(i.validationBorder,"#333333"),"--cfm-validation-bg":a(i.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":a(i.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${w(i.progressTrackHeight,12)}px`,"--cfm-progress-track":a(i.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":a(i.progressFillColor,a(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${w(i.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${w(i.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":a(i.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":a(i.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":a(i.languageSelectorBorderColor,"#2563EB")},T=[["MCQ",Ot],["TEXTFIELD",Ut],["NPS_SCALE",zt],["CFM_MATRIX",qt],["CSAT_MATRIX",Wt],["RATING_MATRIX",Xt],["SLIDER_MATRIX",Ht],["FILE_UPLOAD",Vt],["TEXT_AND_MEDIA",Jt],["HEATMAP",Gt],["RANK_ORDER",Qt]];for(let[$,b]of T){let P=X(m[$]);P&&b(h,P)}return h}function to(e){let o=e.questionTypes??{},t=X(o.MCQ),n=X(o.NPS_SCALE),r=X(o.FILE_UPLOAD),i={};return i["data-cfm-mcq-style"]=a(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(i["data-cfm-nps-button-style"]=a(n.buttonStyle,"numbered")),r?.dropzoneStyle&&(i["data-cfm-dropzone-style"]=a(r.dropzoneStyle,"dashed")),i}var Do,Lo,Mo,no=q(()=>{"use strict";Do={narrow:"36rem",standard:"48rem",wide:"64rem"},Lo={sharp:"0px",rounded:"12px",pill:"9999px"},Mo={system:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',inter:"Inter, system-ui, sans-serif",modern:"Inter, sans-serif",roboto:"Roboto, system-ui, sans-serif",openSans:'"Open Sans", system-ui, sans-serif',lato:"Lato, system-ui, sans-serif",poppins:"Poppins, system-ui, sans-serif",montserrat:"Montserrat, system-ui, sans-serif",nunito:"Nunito, system-ui, sans-serif",raleway:"Raleway, system-ui, sans-serif",sourceSans:'"Source Sans 3", system-ui, sans-serif',georgia:'Georgia, "Times New Roman", serif',serif:"Georgia, serif",merriweather:"Merriweather, Georgia, serif",playfair:'"Playfair Display", Georgia, serif'}});function Kt(e){return`:root {
|
|
2
|
+
"use strict";var dt=Object.create;var Ve=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var q=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ne=(e,o)=>{for(var t in o)Ve(e,t,{get:o[t],enumerable:!0})},mt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of pt(o))!ut.call(e,i)&&i!==t&&Ve(e,i,{get:()=>o[i],enumerable:!(n=ft(o,i))||n.enumerable});return e};var E=(e,o,t)=>(t=e!=null?dt(gt(e)):{},mt(o||!e||!e.__esModule?Ve(t,"default",{value:e,enumerable:!0}):t,e));var a,W=q(()=>{"use strict";a={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"}});var Q,xe=q(()=>{"use strict";Q=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function wt(e){let o={};for(let t of e)wo[t]&&(o[t]={...wo[t]});return o}function bt(e=[],o){return{version:"1.0",instanceId:o,surveyTypes:e,global:{surveyTitle:"Customer Feedback Survey",companyName:"Sprinklr",browserTabTitle:"Customer Feedback Survey",thankYouMessage:"Thank you for your valuable feedback!",logo:{fileName:null,url:null},header:{height:120,logoBoxWidth:120,logoBoxHeight:120,logoPadding:10,logoPlacement:"left",showCompanyName:!0,companyNamePlacement:"left",companyNameFontSize:18,companyNameFontWeight:600,companyNameColor:"#1A1F36",backgroundColor:"#FFFFFF",shadowEnabled:!0,borderBottomColor:"#E5E7EB",contentPaddingX:40},footer:{backgroundColor:"#262626",textColor:"#9CA3AF",linkColor:"#9CA3AF",linkHoverColor:"#FFFFFF",showLogo:!0,logoWidth:120,logoHeight:32,logoPlacement:"left",copyrightText:"\xA9 Company Name",layout:"row",paddingY:21,paddingX:40,links:[]},theme:{pageBackground:"#FFFFFF",cardBackground:"#FFFFFF",cardBorderColor:"#E5E7EB",cardPadding:24,cardShadowEnabled:!0,selectedBackground:"#E8F5FD",zebraRowColor:"rgba(249,250,251,0.8)",rowBandColor:"#F3F4F6",validationBorder:"#333333",validationBackground:"#D9D9D9",tooltipBackground:"#1F2937",progressTrackHeight:12,progressTrackColor:"#E5E7EB",progressFillColor:"#1A1F36",stickyChromePaddingTop:16,stickyChromePaddingBottom:20,languageSelectorBackground:"#FFFFFF",languageSelectorTextColor:"#2563EB",languageSelectorBorderColor:"#2563EB"},layout:{showHeader:!0,showFooter:!0,showProgressBar:!0,showLanguageSwitcher:!1,showNextButton:!0,showBackButton:!0,showQuestionNumbers:!0,showRequiredAsterisk:!0,width:"standard",borderStyle:"rounded",fontStyle:"modern"},buttons:{next:"Next",back:"Back",submit:"Submit"},colorScheme:{...B},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:wt(e),placeholders:{firstName:"Alex",lastName:"Customer",email:"alex@example.com"},customFields:{},debug:{enabled:!1,sampleAnswers:{}},deploy:{target:"aws",autoDeploy:!1}}}function oe(e,o){return{...e,...o??{}}}function De(e){let o=(e.surveyTypes??[]).filter(c=>Q.includes(c)),t=[...new Set([...o,...Q])],n=bt(t,e.instanceId),i=e.global??{},r=n.global,s={...n.questionTypes};if(e.questionTypes)for(let[c,d]of Object.entries(e.questionTypes))s[c]={...s[c]??{},...d};return{...n,...e,configuredAt:void 0,surveyTypes:o.length?o:n.surveyTypes,global:{...r,...i,header:oe(r.header,i.header),footer:oe(r.footer,i.footer),theme:oe(r.theme,i.theme),layout:oe(r.layout,i.layout),buttons:oe(r.buttons,i.buttons),logo:oe(r.logo,i.logo),colorScheme:oe(r.colorScheme,i.colorScheme),typography:oe(r.typography,i.typography),motion:oe(r.motion,i.motion)},questionTypes:s,placeholders:{...n.placeholders,...e.placeholders??{}},customFields:{...n.customFields,...e.customFields??{}},debug:{enabled:e.debug?.enabled??n.debug?.enabled??!1,sampleAnswers:e.debug?.sampleAnswers??n.debug?.sampleAnswers},deploy:{...n.deploy,...e.deploy??{}}}}var B,wo,Je=q(()=>{"use strict";xe();B={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},wo={MCQ:{cardStyle:"outlined",selectedAccent:B.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:B.secondary,hoverBorderColor:B.accent},TEXTFIELD:{inputRadius:8,focusRing:B.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:B.secondary,labelColor:B.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:B.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:B.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:B.primary,cellPadding:8,accentColor:B.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:B.accent,cellSize:40,tooltipBg:"#1F2937",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:B.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:B.primary,rowLabelWidth:180,unselectedStarOpacity:.5,graphicsTrackColor:"#E5E7EB",graphicsThumbColor:B.primary},SLIDER_MATRIX:{trackColor:B.accent,thumbColor:B.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:B.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:B.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:B.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:B.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});function xo(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let i=n[0].split(":")[0].trim(),r=n[1].trim();o[i]=r}return o}function k(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function To(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function $e(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function $o(e){let o={global:{},questionTypes:{}},t=o.global,n={},i={},r={},s={},c={},d={},y={},m=o.questionTypes;if(e["--cfm-primary"]&&(n.primary=e["--cfm-primary"]),e["--cfm-secondary"]&&(n.secondary=e["--cfm-secondary"]),e["--cfm-accent"]&&(n.accent=e["--cfm-accent"]),e["--cfm-background"]&&(n.background=e["--cfm-background"]),e["--cfm-text"]&&(n.text=e["--cfm-text"]),e["--cfm-button-text"]&&(n.buttonText=e["--cfm-button-text"]),e["--cfm-max-width"]&&bo[e["--cfm-max-width"]]&&(c.width=bo[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&So[e["--cfm-border-radius"]]&&(c.borderStyle=So[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],Co[e["--cfm-font-family"]]&&(c.fontStyle=Co[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=$e(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let $=k(e["--cfm-motion-duration"]);$!==void 0&&(y.durationMs=$,y.enabled=$>0)}e["--cfm-header-height"]&&(i.height=k(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(i.logoBoxWidth=k(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(i.logoBoxHeight=k(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(i.logoPadding=k(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(i.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(i.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(i.companyNameFontSize=k(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(i.companyNameFontWeight=$e(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(i.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(i.contentPaddingX=k(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(r.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(r.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(r.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(r.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(r.logoWidth=k(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(r.logoHeight=k(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(r.paddingY=k(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(r.paddingX=k(e["--cfm-footer-padding-x"])),e["--cfm-background"]&&(s.pageBackground=e["--cfm-background"]),e["--cfm-card-bg"]&&(s.cardBackground=e["--cfm-card-bg"]),e["--cfm-card-border-color"]&&(s.cardBorderColor=e["--cfm-card-border-color"]),e["--cfm-card-padding"]&&(s.cardPadding=k(e["--cfm-card-padding"])),e["--cfm-card-shadow"]&&(s.cardShadowEnabled=e["--cfm-card-shadow"]!=="none"),e["--cfm-selected-bg"]&&(s.selectedBackground=e["--cfm-selected-bg"]),e["--cfm-zebra-row"]&&(s.zebraRowColor=e["--cfm-zebra-row"]),e["--cfm-row-band"]&&(s.rowBandColor=e["--cfm-row-band"]),e["--cfm-validation-border"]&&(s.validationBorder=e["--cfm-validation-border"]),e["--cfm-validation-bg"]&&(s.validationBackground=e["--cfm-validation-bg"]),e["--cfm-tooltip-bg"]&&(s.tooltipBackground=e["--cfm-tooltip-bg"]),e["--cfm-progress-height"]&&(s.progressTrackHeight=k(e["--cfm-progress-height"])),e["--cfm-progress-track"]&&(s.progressTrackColor=e["--cfm-progress-track"]),e["--cfm-progress-fill"]&&(s.progressFillColor=e["--cfm-progress-fill"]),e["--cfm-sticky-pt"]&&(s.stickyChromePaddingTop=k(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=k(e["--cfm-sticky-pb"]));let b={};e["--cfm-mcq-selected-accent"]&&(b.selectedAccent=e["--cfm-mcq-selected-accent"]),e["--cfm-mcq-border-radius"]&&(b.borderRadius=k(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(b.optionGap=k(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(b.cardPadding=k(e["--cfm-mcq-card-padding"])),e["--cfm-mcq-selected-bg"]&&(b.selectedBackground=e["--cfm-mcq-selected-bg"]),e["--cfm-mcq-hover-border"]&&(b.hoverBorderColor=e["--cfm-mcq-hover-border"]),Object.keys(b).length&&(m.MCQ=b);let x={};e["--cfm-input-radius"]&&(x.inputRadius=k(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(x.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(x.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(x.inputPadding=k(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=k(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(m.TEXTFIELD=x);let A={};e["--cfm-nps-selected-fill"]&&(A.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(A.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(A.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(A.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(A.cellSize=k(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(A.cellGap=k(e["--cfm-nps-cell-gap"])),Object.keys(A).length&&(m.NPS_SCALE=A);let F=k(e["--cfm-matrix-row-width"]),R={};F!==void 0&&(R.rowLabelWidth=F),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=To(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&(R.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&(R.cellPadding=k(e["--cfm-matrix-cell-padding"])),Object.keys(R).length&&(m.CFM_MATRIX=R);let S={...R};e["--cfm-csat-accent"]&&(S.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(S.emojiSize=k(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(S.unselectedOpacity=$e(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(S.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(S.cellSize=k(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(S.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(S).length>Object.keys(R).length||e["--cfm-csat-accent"])&&(m.CSAT_MATRIX=S);let f={};e["--cfm-star-color"]&&(f.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(f.badgeColor=e["--cfm-badge-color"]),F!==void 0&&(f.rowLabelWidth=F),e["--cfm-star-unselected-opacity"]&&(f.unselectedStarOpacity=$e(e["--cfm-star-unselected-opacity"])),Object.keys(f).length&&(m.RATING_MATRIX=f);let P={};e["--cfm-slider-track"]&&(P.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(P.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(P.tickColor=e["--cfm-slider-tick"]),F!==void 0&&(P.rowLabelWidth=F),e["--cfm-slider-row-band"]&&(P.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(P.tickBadgeSize=k(e["--cfm-slider-tick-size"])),Object.keys(P).length&&(m.SLIDER_MATRIX=P);let I={};e["--cfm-upload-accent"]&&(I.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&(I.dropzonePadding=k(e["--cfm-upload-padding"])),Object.keys(I).length&&(m.FILE_UPLOAD=I);let u={};e["--cfm-media-max-width"]&&(u.mediaMaxWidth=To(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(u.mediaRadius=k(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(u.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(u.captionSize=k(e["--cfm-media-caption-size"])),Object.keys(u).length&&(m.TEXT_AND_MEDIA=u);let C={};e["--cfm-heatmap-pin"]&&(C.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(C.pinSize=k(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(C.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(C.overlayOpacity=$e(e["--cfm-heatmap-overlay-opacity"])),Object.keys(C).length&&(m.HEATMAP=C);let T={};return e["--cfm-rank-item-bg"]&&(T.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(T.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(T.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(T.itemPadding=k(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(T.itemGap=k(e["--cfm-rank-item-gap"])),Object.keys(T).length&&(m.RANK_ORDER=T),Object.keys(n).length&&(t.colorScheme=n),Object.keys(i).length&&(t.header=i),Object.keys(r).length&&(t.footer=r),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(y).length&&(t.motion=y),o}function ge(e){let o=[Re.join(e,"src","styles","survey-theme.css"),Re.join(e,"src","app","survey-theme.css"),Re.join(e,"src","styles","globals.css"),Re.join(e,"src","app","globals.css")];for(let t of o)if(Le.existsSync(t)&&Le.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var Le,Re,bo,So,Co,Me=q(()=>{"use strict";Le=E(require("fs")),Re=E(require("path")),bo={"36rem":"narrow","48rem":"standard","64rem":"wide"},So={"0px":"sharp","12px":"rounded","9999px":"pill"},Co={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});function Ct(e){for(let o of St){let t=Ro.join(e,o);if(Be.existsSync(t))return t}return null}function Tt(e){let o=e.trim();if(!o||o.startsWith("http")||o.startsWith("data:"))return null;let t=o.split("?")[0];return t.startsWith("/")?t.slice(1):t}function Ao(e){let o=Ct(e);if(!o)return null;let t=Be.readFileSync(o,"utf8"),n=t.match(/data-cfm-logo[\s\S]*?src=["']([^"']+)["']/i)??t.match(/src=["']([^"']+)["'][\s\S]*?data-cfm-logo/i);if(n){let s=Tt(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let i=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(i)return{mode:"text",label:i[1].trim()};let r=t.match(/data-cfm-company[^>]*>([^<]+)</i);return r&&!n?{mode:"text",label:r[1].trim()}:null}var Be,Ro,St,Eo=q(()=>{"use strict";Be=E(require("fs")),Ro=E(require("path")),St=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var jo={};Ne(jo,{logSeedSource:()=>Qe,resolveInitialConfig:()=>me,writeResolvedUiConfig:()=>Ke});function Ge(e){return e.filter(o=>Q.includes(o))}function ko(e){try{let o=JSON.parse(K.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function Rt(e){let o={global:{}};if(!K.existsSync(e))return o;let t=K.readFileSync(e,"utf8"),n=new Set;for(let r of Q)t.includes(r)&&n.add(r);n.size&&(o.surveyTypes=[...n]);let i=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(i){let r=i[1].trim(),s=r.match(/company[:\s]+([^,;]+)/i),c=r.match(/title[:\s]+([^,;]+)/i);if(s&&(o.global.companyName=s[1].trim()),c){let d=c[1].trim();o.global.surveyTitle=d,o.global.browserTabTitle=d}}return o}function Io(e,o){let t=te.join(e,o);if(!K.existsSync(t))return null;let n=K.readFileSync(t);if(n.length>xt)return{fileName:o,dataUrl:""};let i=te.extname(o).toLowerCase(),r=$t[i]??"application/octet-stream";return{fileName:o,dataUrl:`data:${r};base64,${n.toString("base64")}`}}function Fo(e,o){if(!o)return null;if(o.url&&typeof o.url=="string")return{fileName:o.fileName??null,url:o.url};if(o.fileName){let t=Io(e,o.fileName);if(t)return{fileName:t.fileName,url:t.dataUrl||null}}return o.fileName===null&&o.url===null?{fileName:null,url:null}:null}function Po(e,o){let t=e.global??{},n=o.global??{},i=e.questionTypes??{},r=o.questionTypes??{},s={...i};for(let[c,d]of Object.entries(r))s[c]={...s[c]??{},...d};return{...e,...o,surveyTypes:o.surveyTypes??e.surveyTypes,global:{...t,...n,header:{...t.header,...n.header},footer:{...t.footer,...n.footer},theme:{...t.theme,...n.theme},layout:{...t.layout,...n.layout},buttons:{...t.buttons,...n.buttons},logo:{...t.logo,...n.logo},colorScheme:{...t.colorScheme,...n.colorScheme},typography:{...t.typography,...n.typography},motion:{...t.motion,...n.motion}},questionTypes:s,placeholders:{...e.placeholders,...o.placeholders},customFields:{...e.customFields,...o.customFields},deploy:{...e.deploy,...o.deploy}}}function me(e){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=te.join(o,"survey-ui-config.json"),n=te.join(o,"implementation_plan.md"),i=te.join(o,"public"),r=Ge(e.surveyTypes),s={},c="defaults",d=ge(o);if(d){let T=K.readFileSync(d,"utf8"),$=xo(T);Object.keys($).length>0&&(s=$o($),c="survey-theme.css")}let y=Rt(n);s=Po(s,y);let m=ko(t);m&&(s=Po(s,m),c="survey-ui-config.json");let b=te.join(o,"survey-ui-config.final.json"),x=ko(b),A=!!m?.configuredAt,F=!!x?.configuredAt;if(x&&F&&!A){let T=Fo(i,x.global?.logo);T&&(s.global={...s.global??{},logo:{fileName:T.fileName,url:T.url}})}let R=Fo(i,s.global?.logo),S=Ao(o),f=!!m?.configuredAt,P=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),I=S?.mode==="image"?S.fileName:null,u=!f&&P&&I!=null&&R?.fileName!==I;if(R&&!u)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(S?.mode==="image"){let T=Io(i,S.fileName);s.global={...s.global??{},logo:{fileName:S.fileName,url:T?.dataUrl||null}}}else S?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??S.label});return s.surveyTypes=Ge(s.surveyTypes??r),s.surveyTypes?.length||(s.surveyTypes=r),e.instanceId&&(s.instanceId=e.instanceId),{config:De(s),source:c}}function Qe(e){console.log(e==="survey-ui-config.json"?`${ue.dim} Seeding wizard from survey-ui-config.json${ue.reset}`:e==="survey-theme.css"?`${ue.dim} Seeding wizard from survey-theme.css + defaults${ue.reset}`:`${ue.dim} Seeding wizard from SDK defaults${ue.reset}`)}function Ke(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??Ge(Q),{config:n}=me({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),i=te.join(o,"survey-ui-config.json");return K.writeFileSync(i,JSON.stringify(n,null,2),"utf8"),i}var K,te,ue,xt,$t,Ae=q(()=>{"use strict";K=E(require("fs")),te=E(require("path"));W();Je();Me();xe();Eo();ue=a,xt=512e3,$t={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function w(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function l(e,o){return typeof e=="string"&&e.length?e:o}function Mt(){return{"--cfm-header-brand-gap":"16px","--cfm-header-padding-y":"12px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0","--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start"}}function Bt(){return{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":"start","--cfm-footer-links-col":"3","--cfm-footer-links-justify":"end","--cfm-footer-logo-copyright-gap":"12px"}}function Ue(e,o){o.numberLabelMode&&(e["--cfm-number-label-mode"]=l(o.numberLabelMode,"traffic")),o.monochromeNumberColor&&(e["--cfm-number-mono-color"]=l(o.monochromeNumberColor,"#9CA3AF"));let t=o.individualNumberColors;Array.isArray(t)&&t.forEach((n,i)=>{typeof n=="string"&&(e[`--cfm-number-color-${i}`]=n)})}function Uo(e,o){o.hintLabelColor&&(e["--cfm-hint-label-color"]=l(o.hintLabelColor,"#6B7280")),o.hintLabelBgColor&&(e["--cfm-hint-label-bg"]=l(o.hintLabelBgColor,"transparent"))}function to(e,o,t){(t==="matrix"||t==="csat")&&(o.columnLabelColor&&(e["--cfm-matrix-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-matrix-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="csat"&&(o.columnLabelColor&&(e["--cfm-csat-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-csat-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="rating"&&(o.columnLabelColor&&(e["--cfm-rating-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-rating-column-label-bg"]=l(o.columnLabelBgColor,"transparent")))}function Ot(e,o){let t=l(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${w(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${w(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${w(o.optionPadding??o.cardPadding,12)}px`,e["--cfm-mcq-hover-border"]=l(o.hoverBorderColor,"#00B5AD"),e["--cfm-mcq-option-style"]=t,o.filledOptionBg&&(e["--cfm-mcq-filled-bg"]=l(o.filledOptionBg,"#F9FAFB"))}function Ut(e,o){e["--cfm-input-radius"]=`${w(o.inputRadius,8)}px`,e["--cfm-input-border"]=l(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${w(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${w(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=l(o.placeholderColor,"#9CA3AF")}function zt(e,o){e["--cfm-nps-cell-size"]=`${w(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${w(o.cellGap,4)}px`,e["--cfm-nps-button-style"]=l(o.buttonStyle,"numbered"),e["--cfm-nps-selected-fill"]=l(o.selectedFill,"#E8F5FD"),e["--cfm-nps-track-bar"]=l(o.trackBarColor,"#F2F2F2"),e["--cfm-nps-track-highlight"]=l(o.trackHighlightColor,"#FBE8F3"),o.hintMinText&&(e["--cfm-hint-min-text"]=l(o.hintMinText,"")),o.hintMaxText&&(e["--cfm-hint-max-text"]=l(o.hintMaxText,"")),Uo(e,o),Ue(e,o)}function qt(e,o){e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${w(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${w(o.cellPadding,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=l(o.carouselDotColor,"#2563EB")),to(e,o,"matrix")}function Wt(e,o){e["--cfm-csat-emoji-size"]=`${w(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(w(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(w(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${w(o.cellSize,40)}px`,e["--cfm-csat-tooltip-bg"]=l(o.tooltipBg,"#1F2937"),e["--cfm-csat-accent"]=l(o.accentColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-accent"]??"#00B5AD"),to(e,o,"csat"),Ue(e,o)}function Xt(e,o){e["--cfm-star-color"]=l(o.starColor,"#F59E0B"),e["--cfm-badge-color"]=l(o.badgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-csat-emoji-size"]=`${w(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(w(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(w(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-primary"]??"#1A1F36"),to(e,o,"rating"),Ue(e,o)}function Ht(e,o){e["--cfm-slider-track"]=l(o.trackColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-slider-thumb"]=l(o.thumbColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-slider-tick"]=l(o.tickColor,"#9CA3AF"),e["--cfm-matrix-row-width"]=`${w(o.rowLabelWidth,180)}px`,e["--cfm-slider-row-band"]=l(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${w(o.tickBadgeSize,28)}px`,Uo(e,o),Ue(e,o)}function Vt(e,o){e["--cfm-upload-border-color"]=l(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${w(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=l(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=l(o.dropzoneStyle,"dashed")}function Jt(e,o){e["--cfm-media-max-width"]=`${w(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${w(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=l(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${w(o.captionSize,14)}px`}function Gt(e,o){e["--cfm-heatmap-pin"]=l(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${w(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=l(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(w(o.overlayOpacity,0))}function Qt(e,o){let t=X(o.drag)??o,n=X(o.dropdown)??t,i=l(n.itemHoverBg??t.itemHoverBg,"#F3F4F6");e["--cfm-rank-item-bg"]=l(t.itemBg??n.itemBg,"#F9FAFB"),e["--cfm-rank-dropdown-hover-bg"]=i,e["--cfm-rank-badge-bg"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-badge-text"]="#ffffff",e["--cfm-rank-badge"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-item-padding"]=`${w(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${w(t.itemGap,8)}px`,e["--cfm-rank-handle"]=l(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=l(n.selectBorderColor,"#E5E7EB")}function ze(e){let o=X(e.global)??{},t=X(o.colorScheme)??{},n=X(o.header)??{},i=X(o.footer)??{},r=X(o.theme)??{},s=X(o.layout)??{},c=X(o.typography)??{},d=X(o.motion)??{},y=e.questionTypes??{},m=l(s.fontStyle,"modern"),b=Oo[m]??l(c.fontFamily,Oo.modern),x=l(s.width,"standard"),A=l(s.borderStyle,"rounded"),F=l(r.cellSelectedColor,l(t.accent,"#00B5AD")),R=l(r.focusRingColor,l(t.accent,"#00B5AD")),S=l(r.selectedBackground,l(t.secondary,"#E8F5FD")),f={"--cfm-primary":l(t.primary,"#1A1F36"),"--cfm-secondary":l(t.secondary,"#E8F5FD"),"--cfm-accent":l(t.accent,"#00B5AD"),"--cfm-background":l(r.pageBackground??t.background,"#FFFFFF"),"--cfm-text":l(t.text,"#1A1F36"),"--cfm-button-text":l(t.buttonText,"#FFFFFF"),"--cfm-max-width":Mo[x]??Mo.standard,"--cfm-border-radius":Bo[A]??Bo.rounded,"--cfm-font-family":b,"--cfm-heading-weight":String(w(c.headingWeight,700)),"--cfm-motion-duration":`${w(d.durationMs,200)}ms`,"--cfm-header-height":`${w(n.height,120)}px`,"--cfm-header-logo-width":`${w(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${w(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${w(n.logoPadding,10)}px`,"--cfm-header-show-company":n.showCompanyName===!1?"0":"1","--cfm-header-bg":l(n.backgroundColor,"#FFFFFF"),"--cfm-header-company-color":l(n.companyNameColor,l(t.text,"#1A1F36")),"--cfm-header-company-size":`${w(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(w(n.companyNameFontWeight,600)),"--cfm-header-border":l(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${w(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",...Mt(),"--cfm-footer-bg":l(i.backgroundColor,"#262626"),"--cfm-footer-text":l(i.textColor,"#9CA3AF"),"--cfm-footer-link":l(i.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":l(i.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${w(i.logoWidth,120)}px`,"--cfm-footer-logo-height":`${w(i.logoHeight,32)}px`,"--cfm-footer-padding-y":`${w(i.paddingY,24)}px`,"--cfm-footer-padding-x":`${w(i.paddingX,40)}px`,...Bt(),"--cfm-card-bg":l(r.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(r.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${w(r.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":r.cardShadowEnabled===!1?"none":`0 ${w(r.cardShadowOffsetY,1)}px ${w(r.cardShadowBlur,3)}px ${l(r.cardShadowColor,"rgba(0,0,0,0.1)")}`,"--cfm-selected-bg":S,"--cfm-mcq-selected-accent":R,"--cfm-mcq-selected-bg":S,"--cfm-matrix-selected":F,"--cfm-csat-ring-color":F,"--cfm-input-focus-ring":R,"--cfm-zebra-row":l(r.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":l(r.rowBandColor,"#F3F4F6"),"--cfm-validation-border":l(r.validationBorder,"#333333"),"--cfm-validation-bg":l(r.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":l(r.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${w(r.progressTrackHeight,12)}px`,"--cfm-progress-track":l(r.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(r.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${w(r.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${w(r.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":l(r.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":l(r.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":l(r.languageSelectorBorderColor,"#2563EB")},P=[["MCQ",Ot],["TEXTFIELD",Ut],["NPS_SCALE",zt],["CFM_MATRIX",qt],["CSAT_MATRIX",Wt],["RATING_MATRIX",Xt],["SLIDER_MATRIX",Ht],["FILE_UPLOAD",Vt],["TEXT_AND_MEDIA",Jt],["HEATMAP",Gt],["RANK_ORDER",Qt]];for(let[I,u]of P){let C=X(y[I]);C&&u(f,C)}return f}function no(e){let o=e.questionTypes??{},t=X(o.MCQ),n=X(o.NPS_SCALE),i=X(o.FILE_UPLOAD),r={};return r["data-cfm-mcq-style"]=l(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(r["data-cfm-nps-button-style"]=l(n.buttonStyle,"numbered")),i?.dropzoneStyle&&(r["data-cfm-dropzone-style"]=l(i.dropzoneStyle,"dashed")),r}var Mo,Bo,Oo,io=q(()=>{"use strict";Mo={narrow:"36rem",standard:"48rem",wide:"64rem"},Bo={sharp:"0px",rounded:"12px",pill:"9999px"},Oo={system:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',inter:"Inter, system-ui, sans-serif",modern:"Inter, sans-serif",roboto:"Roboto, system-ui, sans-serif",openSans:'"Open Sans", system-ui, sans-serif',lato:"Lato, system-ui, sans-serif",poppins:"Poppins, system-ui, sans-serif",montserrat:"Montserrat, system-ui, sans-serif",nunito:"Nunito, system-ui, sans-serif",raleway:"Raleway, system-ui, sans-serif",sourceSans:'"Source Sans 3", system-ui, sans-serif',georgia:'Georgia, "Times New Roman", serif',serif:"Georgia, serif",merriweather:"Merriweather, Georgia, serif",playfair:'"Playfair Display", Georgia, serif'}});function Kt(e){return`:root {
|
|
3
3
|
${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>` ${t}: ${n};`).join(`
|
|
4
4
|
`)}
|
|
5
|
-
}`}function Yt(e,o){let t=
|
|
5
|
+
}`}function Yt(e,o){let t=ze(e),n=Kt(t),i=o.match(/:root\s*\{[\s\S]*?\n\}/);return i?o.replace(i[0],n):`${n}
|
|
6
6
|
|
|
7
|
-
${o}`}function Zt(e){let o=ce.join(e,"src","styles","survey-theme.css");if(
|
|
8
|
-
`)}function
|
|
9
|
-
${s}`,
|
|
7
|
+
${o}`}function Zt(e){let o=ce.join(e,"src","styles","survey-theme.css");if(ne.existsSync(ce.dirname(o)))return o;let t=ce.join(e,"src","app","survey-theme.css");return ne.existsSync(ce.dirname(t))?t:(ne.mkdirSync(ce.dirname(o),{recursive:!0}),o)}function zo(e,o,t){let n=ne.readFileSync(t,"utf8"),i=Zt(e),r=Yt(o,n);return ne.writeFileSync(i,r,"utf8"),i}var ne,ce,qo=q(()=>{"use strict";ne=E(require("fs")),ce=E(require("path"));io()});function Wo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xo(e,o){return JSON.stringify(e)===JSON.stringify(o)}function he(e){return typeof e=="string"&&e.startsWith("data:")&&e.length>80?`${e.slice(0,48)}\u2026 (${e.length} chars)`:e}function Ho(e,o,t,n){if(Xo(e,o)){n.unchangedCount+=1;return}if(e===void 0&&o!==void 0){n.added.push({path:t,before:void 0,after:he(o)});return}if(e!==void 0&&o===void 0){n.removed.push({path:t,before:he(e),after:void 0});return}if(Array.isArray(e)&&Array.isArray(o)){Xo(e,o)?n.unchangedCount+=1:n.changed.push({path:t,before:he(e),after:he(o)});return}if(Wo(e)&&Wo(o)){let i=new Set([...Object.keys(e),...Object.keys(o)]);for(let r of i){if(en.has(r)&&t==="")continue;let s=t?`${t}.${r}`:r;Ho(e[r],o[r],s,n)}return}n.changed.push({path:t,before:he(e),after:he(o)})}function ro(e,o){let t={changed:[],added:[],removed:[],unchangedCount:0};return Ho(e,o,"",t),t}function qe(e){let o=["# UI Config Diff (seed \u2192 final)","",`**Changed:** ${e.changed.length} \xB7 **Added:** ${e.added.length} \xB7 **Removed:** ${e.removed.length}`,"","> Review only \u2014 run `npx cfm-sdk confirm-ui-config` to apply final config to the project.",""],t=(n,i)=>{if(i.length){o.push(`## ${n}`,"");for(let r of i)o.push(`### \`${r.path}\``),o.push(`- **Before:** \`${JSON.stringify(r.before)}\``),o.push(`- **After:** \`${JSON.stringify(r.after)}\``),o.push("")}};return t("Changed",e.changed),t("Added",e.added),t("Removed",e.removed),!e.changed.length&&!e.added.length&&!e.removed.length&&o.push("_No differences \u2014 final config matches seed._",""),o.join(`
|
|
8
|
+
`)}function ie(e){return{seedPath:be.join(e,"survey-ui-config.seed.json"),finalPath:be.join(e,"survey-ui-config.final.json"),diffJsonPath:be.join(e,"survey-ui-config.diff.json"),diffMdPath:be.join(e,"survey-ui-config.diff.md"),activeConfigPath:be.join(e,"survey-ui-config.json")}}function We(e,o,t){let n=ie(e),i=ro(o,t);return we.writeFileSync(n.seedPath,JSON.stringify(o,null,2),"utf8"),we.writeFileSync(n.finalPath,JSON.stringify(t,null,2),"utf8"),we.writeFileSync(n.diffJsonPath,JSON.stringify(i,null,2),"utf8"),we.writeFileSync(n.diffMdPath,qe(i),"utf8"),we.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),i}var we,be,en,Ee=q(()=>{"use strict";we=E(require("fs")),be=E(require("path")),en=new Set(["configuredAt","instanceId"])});function Jo(e){return Vo[e]?Vo[e]:/individualNumberColors\.\d+/.test(e)||e.startsWith("questionTypes.")&&e.includes("columnLabel")||e.startsWith("questionTypes.")&&e.includes("hintLabel")||e.startsWith("questionTypes.")&&e.includes("numberLabel")?"css":e.startsWith("customFields.")||e.startsWith("placeholders.")?"runtime":"unknown"}var Vo,Go=q(()=>{"use strict";Vo={"global.colorScheme.primary":"css","global.colorScheme.secondary":"css","global.colorScheme.accent":"css","global.colorScheme.background":"css","global.colorScheme.text":"css","global.colorScheme.buttonText":"css","global.theme.pageBackground":"css","global.theme.cardBackground":"css","global.theme.cardBorderColor":"css","global.theme.cardPadding":"css","global.theme.cardShadowEnabled":"css","global.theme.cardShadowColor":"css","global.theme.cardShadowBlur":"css","global.theme.cardShadowOffsetY":"css","global.theme.cellSelectedColor":"css","global.theme.focusRingColor":"css","global.theme.selectedBackground":"css","global.theme.zebraRowColor":"css","global.theme.rowBandColor":"css","global.theme.validationBorder":"css","global.theme.validationBackground":"css","global.theme.tooltipBackground":"css","global.theme.progressTrackHeight":"css","global.theme.progressTrackColor":"css","global.theme.progressFillColor":"css","global.theme.stickyChromePaddingTop":"css","global.theme.stickyChromePaddingBottom":"css","global.theme.languageSelectorBackground":"css","global.theme.languageSelectorTextColor":"css","global.theme.languageSelectorBorderColor":"css","global.header.height":"css","global.header.logoBoxWidth":"css","global.header.logoBoxHeight":"css","global.header.logoPadding":"css","global.header.logoPlacement":"css","global.header.showCompanyName":"css","global.header.companyNamePlacement":"css","global.header.companyNameFontSize":"css","global.header.companyNameFontWeight":"css","global.header.companyNameColor":"css","global.header.backgroundColor":"css","global.header.shadowEnabled":"css","global.header.borderBottomColor":"css","global.header.contentPaddingX":"css","global.footer.backgroundColor":"css","global.footer.textColor":"css","global.footer.linkColor":"css","global.footer.linkHoverColor":"css","global.footer.showLogo":"layout","global.footer.logoWidth":"css","global.footer.logoHeight":"css","global.footer.logoPlacement":"css","global.footer.copyrightText":"content","global.footer.layout":"css","global.footer.paddingY":"css","global.footer.paddingX":"css","global.footer.links":"content","global.layout.showHeader":"layout","global.layout.showFooter":"layout","global.layout.showProgressBar":"layout","global.layout.showLanguageSwitcher":"layout","global.layout.showNextButton":"layout","global.layout.showBackButton":"layout","global.layout.showQuestionNumbers":"layout","global.layout.showRequiredAsterisk":"layout","global.layout.width":"css","global.layout.borderStyle":"css","global.layout.fontStyle":"css","global.typography.fontFamily":"css","global.typography.headingWeight":"css","global.motion.durationMs":"css","global.motion.enabled":"css","global.surveyTitle":"content","global.companyName":"content","global.browserTabTitle":"content","global.thankYouMessage":"content","global.buttons.next":"content","global.buttons.back":"content","global.buttons.submit":"content","global.logo.fileName":"content","global.logo.url":"runtime","questionTypes.MCQ.optionStyle":"dom","questionTypes.MCQ.cardStyle":"dom","questionTypes.MCQ.optionGap":"css","questionTypes.MCQ.borderRadius":"css","questionTypes.MCQ.optionPadding":"css","questionTypes.MCQ.cardPadding":"css","questionTypes.MCQ.hoverBorderColor":"css","questionTypes.MCQ.filledOptionBg":"css","questionTypes.TEXTFIELD.inputRadius":"css","questionTypes.TEXTFIELD.borderColor":"css","questionTypes.TEXTFIELD.inputPadding":"css","questionTypes.TEXTFIELD.inputHeight":"css","questionTypes.TEXTFIELD.placeholderColor":"css","questionTypes.TEXTFIELD.defaultPlaceholder":"runtime","questionTypes.NPS_SCALE.buttonStyle":"dom","questionTypes.NPS_SCALE.trackBarColor":"css","questionTypes.NPS_SCALE.trackHighlightColor":"css","questionTypes.NPS_SCALE.cellSize":"css","questionTypes.NPS_SCALE.cellGap":"css","questionTypes.NPS_SCALE.hintMinText":"runtime","questionTypes.NPS_SCALE.hintMaxText":"runtime","questionTypes.NPS_SCALE.hintLabelColor":"css","questionTypes.NPS_SCALE.hintLabelBgColor":"css","questionTypes.NPS_SCALE.numberLabelMode":"css","questionTypes.NPS_SCALE.monochromeNumberColor":"css","questionTypes.CFM_MATRIX.rowLabelWidth":"css","questionTypes.CFM_MATRIX.bipolarColumnWidthPercent":"css","questionTypes.CFM_MATRIX.cellPadding":"css","questionTypes.CFM_MATRIX.columnLabelColor":"css","questionTypes.CFM_MATRIX.columnLabelBgColor":"css","questionTypes.CSAT_MATRIX.emojiSize":"css","questionTypes.CSAT_MATRIX.unselectedOpacity":"css","questionTypes.CSAT_MATRIX.cellSize":"css","questionTypes.CSAT_MATRIX.tooltipBg":"css","questionTypes.CSAT_MATRIX.rowLabelWidth":"css","questionTypes.CSAT_MATRIX.graphicsTrackColor":"css","questionTypes.CSAT_MATRIX.graphicsThumbColor":"css","questionTypes.CSAT_MATRIX.columnLabelColor":"css","questionTypes.CSAT_MATRIX.columnLabelBgColor":"css","questionTypes.RATING_MATRIX.unselectedStarOpacity":"css","questionTypes.RATING_MATRIX.emojiSize":"css","questionTypes.RATING_MATRIX.rowLabelWidth":"css","questionTypes.RATING_MATRIX.starColor":"css","questionTypes.RATING_MATRIX.badgeColor":"css","questionTypes.RATING_MATRIX.graphicsTrackColor":"css","questionTypes.RATING_MATRIX.graphicsThumbColor":"css","questionTypes.RATING_MATRIX.columnLabelColor":"css","questionTypes.RATING_MATRIX.columnLabelBgColor":"css","questionTypes.SLIDER_MATRIX.trackColor":"css","questionTypes.SLIDER_MATRIX.thumbColor":"css","questionTypes.SLIDER_MATRIX.tickColor":"css","questionTypes.SLIDER_MATRIX.rowLabelWidth":"css","questionTypes.SLIDER_MATRIX.rowBandColor":"css","questionTypes.SLIDER_MATRIX.tickBadgeSize":"css","questionTypes.SLIDER_MATRIX.hintMinText":"runtime","questionTypes.SLIDER_MATRIX.hintMaxText":"runtime","questionTypes.SLIDER_MATRIX.hintLabelColor":"css","questionTypes.SLIDER_MATRIX.hintLabelBgColor":"css","questionTypes.FILE_UPLOAD.dropzoneStyle":"dom","questionTypes.FILE_UPLOAD.borderColor":"css","questionTypes.FILE_UPLOAD.dropzoneFillColor":"css","questionTypes.FILE_UPLOAD.dropzonePadding":"css","questionTypes.TEXT_AND_MEDIA.mediaMaxWidth":"css","questionTypes.TEXT_AND_MEDIA.mediaRadius":"css","questionTypes.TEXT_AND_MEDIA.captionColor":"css","questionTypes.TEXT_AND_MEDIA.captionSize":"css","questionTypes.HEATMAP.pinColor":"css","questionTypes.HEATMAP.pinSize":"css","questionTypes.HEATMAP.pinBorderColor":"css","questionTypes.HEATMAP.overlayOpacity":"css","questionTypes.RANK_ORDER.drag.itemBg":"css","questionTypes.RANK_ORDER.drag.itemHoverBg":"css","questionTypes.RANK_ORDER.drag.rankBadgeColor":"css","questionTypes.RANK_ORDER.drag.dragHandleColor":"css","questionTypes.RANK_ORDER.drag.itemPadding":"css","questionTypes.RANK_ORDER.drag.itemGap":"css","questionTypes.RANK_ORDER.dropdown.itemBg":"css","questionTypes.RANK_ORDER.dropdown.selectBorderColor":"css","questionTypes.RANK_ORDER.dropdown.itemHoverBg":"css","questionTypes.RANK_ORDER.dropdown.itemPadding":"css","questionTypes.RANK_ORDER.dropdown.itemGap":"css","placeholders.firstName":"runtime","placeholders.lastName":"runtime","placeholders.email":"runtime",customFields:"runtime","debug.enabled":"runtime","deploy.target":"runtime","deploy.autoDeploy":"runtime"}});var ke={};Ne(ke,{runApplyUiConfig:()=>ln});function tn(e,o){if(o&&L.existsSync(o))return o;let t=O.join(e,"survey-ui-config.json");if(L.existsSync(t))return t;let n=ie(e).finalPath;if(L.existsSync(n))return n;throw new Error("No survey-ui-config.json found. Complete the wizard or run confirm-ui-config first.")}function nn(e,o){let t=O.relative(O.dirname(o),o),n=(o.includes(`${O.sep}styles${O.sep}`),"./survey-theme.css"),i=[O.join(e,"src","app","globals.css"),O.join(e,"src","styles","globals.css")];for(let r of i){if(!L.existsSync(r))continue;let s=L.readFileSync(r,"utf8"),c=`@import '${n}';`;if(s.includes("survey-theme.css"))return;s.includes(c)||(s=`${c}
|
|
9
|
+
${s}`,L.writeFileSync(r,s,"utf8"));return}}function rn(e,o){let t=no(o),n=O.join(e,"src","lib");L.mkdirSync(n,{recursive:!0});let i=O.join(n,"surveyUiDomAttributes.ts"),s=`/**
|
|
10
10
|
* Runtime DOM attributes for wizard style modes (MCQ / NPS / upload).
|
|
11
11
|
* Auto-generated by \`npx cfm-sdk apply-ui-config\` \u2014 do not edit manually.
|
|
12
12
|
*/
|
|
@@ -16,7 +16,7 @@ export function applySurveyUiDomAttributes(): void {
|
|
|
16
16
|
${Object.entries(t).map(([c,d])=>` root.setAttribute('${c}', ${JSON.stringify(d)});`).join(`
|
|
17
17
|
`)}
|
|
18
18
|
}
|
|
19
|
-
`;return
|
|
19
|
+
`;return L.writeFileSync(i,s,"utf8"),i}function sn(e){let o=O.join(e,"src","components");L.mkdirSync(o,{recursive:!0});let t=O.join(o,"SurveyUiConfigInit.tsx");return L.existsSync(t)||L.writeFileSync(t,on,"utf8"),t}function cn(e,o){let t=O.join(e,"src","lib","uiConfig.ts");if(L.existsSync(t))return;let n=O.join(o,"docs","templates","uiConfig.ts");L.existsSync(n)&&(L.mkdirSync(O.dirname(t),{recursive:!0}),L.copyFileSync(n,t))}function an(e,o){let t=e.replace(/\.json$/,".diff.json");if(L.existsSync(t))try{let n=JSON.parse(L.readFileSync(t,"utf8")),i=[...(n.changed??[]).map(r=>r.path),...(n.added??[]).map(r=>r.path),...(n.removed??[]).map(r=>r.path)];for(let r of i)Jo(r)==="unknown"&&o.push(`Unmapped config path (verify manually): ${r}`)}catch{}}function ln(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=tn(o,e.configPath),n=O.join(__dirname,"..",".."),i=O.join(n,"templates","survey-theme.css"),r=O.join(n,"templates"),s=[],c=JSON.parse(L.readFileSync(t,"utf8")),d=[...new Set([...c.surveyTypes??[],...Q])],y=De({...c,surveyTypes:d}),m=zo(o,y,i);nn(o,m),cn(o,r),rn(o,y);let b;e.skipInitComponent||(b=sn(o));let x=ze(y),A=no(y);an(t,s),console.log(`${Y.green}\u2705 Applied UI config \u2192 ${m}${Y.reset}`),console.log(`${Y.dim} ${Object.keys(x).length} CSS variables regenerated${Y.reset}`),console.log(`${Y.dim} DOM attrs: ${Object.entries(A).map(([F,R])=>`${F}=${R}`).join(", ")}${Y.reset}`),b&&console.log(`${Y.dim} Runtime init: ${b} (mount in layout if not already)${Y.reset}`);for(let F of s)console.log(`${Y.yellow} \u26A0 ${F}${Y.reset}`);return{configPath:t,themeCssPath:m,cssVarCount:Object.keys(x).length,domAttributes:A,initComponentPath:b,warnings:s}}var L,O,Y,on,Fe=q(()=>{"use strict";L=E(require("fs")),O=E(require("path"));W();Je();io();qo();Ee();Go();xe();Y=a,on=`'use client';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Applies wizard DOM attributes from survey-ui-config.json at runtime.
|
|
@@ -32,40 +32,40 @@ export function SurveyUiConfigInit() {
|
|
|
32
32
|
}, []);
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
`});function
|
|
36
|
-
${
|
|
37
|
-
`),console.log(
|
|
38
|
-
${H.green}\u2705 Fetched final config (review mode)${H.reset}`),console.log(`${H.green} Final: ${s.finalPath}${H.reset}`),console.log(`${H.green} Diff: ${s.diffMdPath}${H.reset}`),console.log(`${H.yellow} ${
|
|
39
|
-
`);let o=await
|
|
40
|
-
\u274C ${
|
|
41
|
-
`),process.exit(1));let n=process.platform==="win32",
|
|
42
|
-
\u{1F4E6} ${
|
|
43
|
-
\u2714 ${
|
|
35
|
+
`});function Xe(e){if(!e.config)return null;let o=JSON.parse(JSON.stringify(e.config)),n=o.global?.logo;return e.logoUrl&&n&&(n.url=e.logoUrl),o}function Zo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?ot:et).get(n,r=>{if((r.statusCode??500)>=400){t(new Error(`Logo download failed HTTP ${r.statusCode}`));return}let s=[];r.on("data",c=>s.push(c)),r.on("end",()=>o(Buffer.concat(s)))}).on("error",t)})}async function gn(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?ot:et).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",y=>d+=y),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}async function le(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:i,apiBase:r,surveyId:s}=e,c=ao.join(o,"public");ae.existsSync(c)||ae.mkdirSync(c,{recursive:!0});let d=ao.join(c,t);if(n){let y=await Zo(n);return ae.writeFileSync(d,y),d}if(i&&r&&s){let y=await gn(`${r.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${i}`}}),m=await Zo(y.downloadUrl);return ae.writeFileSync(d,m),d}throw new Error("Logo download requires logoUrl from wizard poll or CFM_INSTANCE_ID + CFM_DEPLOY_API_BASE")}var ae,et,ot,ao,He=q(()=>{"use strict";ae=E(require("fs")),et=E(require("http")),ot=E(require("https")),ao=E(require("path"))});var st={};Ne(st,{runConfirmUiConfig:()=>bn});function wn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function bn(e={}){let o=process.env.INIT_CWD??process.cwd(),t=ie(o);if(!Z.existsSync(t.finalPath))throw new Error(`Missing ${t.finalPath}. Run customize-ui with --review and complete the wizard first.`);let n=JSON.parse(Z.readFileSync(Z.existsSync(t.seedPath)?t.seedPath:t.activeConfigPath,"utf8")),i=JSON.parse(Z.readFileSync(t.finalPath,"utf8")),r=ro(n,i);if(console.log(`
|
|
36
|
+
${V.bold}${V.cyan}\u{1F4CB} UI config review${V.reset}
|
|
37
|
+
`),console.log(qe(r)),e.diffOnly){Z.writeFileSync(t.diffJsonPath,JSON.stringify(r,null,2),"utf8"),Z.writeFileSync(t.diffMdPath,qe(r),"utf8"),console.log(`${V.dim} Updated ${t.diffMdPath}${V.reset}`);return}Z.writeFileSync(t.activeConfigPath,JSON.stringify(i,null,2),"utf8"),console.log(`${V.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${V.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(Fe(),ke));s({projectRoot:o,configPath:t.activeConfigPath});let c=i.global?.logo;if(!c?.fileName)return;let d=process.env.CFM_INSTANCE_ID,y=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),m=d?wn(d):null;try{await le({projectRoot:o,fileName:c.fileName,logoUrl:c.url,jwt:d??void 0,apiBase:y||void 0,surveyId:m??void 0}),console.log(`${V.green} Logo saved to public/${c.fileName}${V.reset}`),c.url&&console.log(`${V.dim} Public logo URL: ${c.url}${V.reset}`)}catch(b){console.log(`${V.yellow} Logo not downloaded \u2014 ${b instanceof Error?b.message:String(b)}${V.reset}`)}}var Z,V,ct=q(()=>{"use strict";Z=E(require("fs"));W();Ee();He();V=a});var at={};Ne(at,{runFetchUiConfig:()=>$n});async function Tn(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Cn:Sn).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",y=>d+=y),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}function xn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function $n(e={}){let o=process.env.CFM_INSTANCE_ID,t=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),n=e.sessionId??process.env.CFM_WIZARD_SESSION_ID;if(!o)throw new Error("CFM_INSTANCE_ID (JWT) is required");if(!t)throw new Error("CFM_DEPLOY_API_BASE is required");if(!n)throw new Error("CFM_WIZARD_SESSION_ID or --session= is required");let i=xn(o);if(!i)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let r=process.env.INIT_CWD??process.cwd(),s=ie(r),c=je.existsSync(s.seedPath)?s.seedPath:s.activeConfigPath;if(!je.existsSync(c))throw new Error(`Missing seed config at ${c}. Run customize-ui --review first.`);let d=await Tn(`${t}/wizard/config/${encodeURIComponent(i)}?sessionId=${encodeURIComponent(n)}`,{headers:{Authorization:`Bearer ${o}`}});if(d.status!=="ready"||!d.config)throw new Error(`Wizard not complete yet (status: ${d.status})`);let y=Xe(d)??d.config,m=JSON.parse(je.readFileSync(c,"utf8")),b=We(r,m,y),x=y.global?.logo;if(x?.fileName)try{await le({projectRoot:r,fileName:x.fileName,logoUrl:d.logoUrl,jwt:o,apiBase:t,surveyId:i}),console.log(`${H.green} Logo saved to public/${x.fileName}${H.reset}`)}catch(A){console.warn(`${H.yellow} Logo download failed: ${A}${H.reset}`)}console.log(`
|
|
38
|
+
${H.green}\u2705 Fetched final config (review mode)${H.reset}`),console.log(`${H.green} Final: ${s.finalPath}${H.reset}`),console.log(`${H.green} Diff: ${s.diffMdPath}${H.reset}`),console.log(`${H.yellow} ${b.changed.length} changed, ${b.added.length} added, ${b.removed.length} removed${H.reset}`),console.log(`${H.dim} Apply when ready: npx cfm-sdk confirm-ui-config${H.reset}`)}var je,Sn,Cn,H,lt=q(()=>{"use strict";je=E(require("fs")),Sn=E(require("http")),Cn=E(require("https"));W();Ee();He();H=a});W();W();var Ce=require("child_process");function fe(e){try{let o=process.platform==="win32"?`where ${e}`:`command -v ${e}`;return(0,Ce.execSync)(o,{stdio:"ignore"}),!0}catch{return!1}}var yt={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function Te(e,o){try{let t=`${e} ${o.join(" ")}`;return(0,Ce.execSync)(t,yt),!0}catch{return!1}}function _e(e,o){return new Promise(t=>{(0,Ce.spawn)(e,o,{stdio:"inherit",shell:!0}).on("close",i=>{t(i)})})}var fo=E(require("readline/promises")),ve=require("process");async function pe(e){let o=fo.default.createInterface({input:ve.stdin,output:ve.stdout});try{return(await o.question(e)).trim()}finally{o.close()}}async function po(){let e=parseInt(process.version.slice(1).split(".")[0],10);if(console.log(`${a.dim}Step 1/4: Checking Node.js version (current: ${process.version})...${a.reset}`),e<18){console.log(`\u26A0\uFE0F ${a.yellow}Outdated Node.js version detected. v18.0.0 or higher is required.${a.reset}`),console.log(`${a.dim}Note: If you already have a higher version installed via nvm, please run 'nvm use <version>' first.${a.reset}
|
|
39
|
+
`);let o=await pe("Would you like to install/upgrade Node.js v18+ automatically? (y/N): ");o.toLowerCase()==="y"||o.toLowerCase()==="yes"||(console.log(`
|
|
40
|
+
\u274C ${a.red}Aborted. Please manually upgrade Node.js to v18+ and try again.${a.reset}
|
|
41
|
+
`),process.exit(1));let n=process.platform==="win32",i=process.platform==="darwin";n?fe("winget")?(console.log(`
|
|
42
|
+
\u{1F4E6} ${a.green}winget package manager found! Installing Node.js v18+ in background...${a.reset}`),Te("winget",["upgrade","OpenJS.NodeJS","--silent","--accept-package-agreements","--accept-source-agreements"])?(console.log(`
|
|
43
|
+
\u2714 ${a.green}Node.js installation triggered successfully. Please restart your terminal/command-prompt for changes to take effect.${a.reset}
|
|
44
44
|
`),process.exit(0)):(console.log(`
|
|
45
|
-
\u274C ${
|
|
45
|
+
\u274C ${a.red}winget update failed. Please update Node.js manually at https://nodejs.org/${a.reset}
|
|
46
46
|
`),process.exit(1))):(console.log(`
|
|
47
|
-
\u274C ${
|
|
48
|
-
`),process.exit(1)):
|
|
49
|
-
\u{1F4E6} ${
|
|
50
|
-
\u2714 ${
|
|
47
|
+
\u274C ${a.red}winget package manager is not installed on this system.${a.reset}`),console.log(`${a.bold}\u{1F449} To proceed, please either:${a.reset}`),console.log(" 1. Install winget (App Installer) from the Microsoft Store."),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
|
|
48
|
+
`),process.exit(1)):i?fe("brew")?(console.log(`
|
|
49
|
+
\u{1F4E6} ${a.green}Homebrew package manager found! Installing Node.js v18+ in background...${a.reset}`),Te("brew",["install","node"])?console.log(`
|
|
50
|
+
\u2714 ${a.green}Node.js installed successfully via Homebrew.${a.reset}
|
|
51
51
|
`):(console.log(`
|
|
52
|
-
\u274C ${
|
|
52
|
+
\u274C ${a.red}Homebrew installation failed. Please install Node.js manually at https://nodejs.org/${a.reset}
|
|
53
53
|
`),process.exit(1))):(console.log(`
|
|
54
|
-
\u274C ${
|
|
54
|
+
\u274C ${a.red}Homebrew package manager (brew) is not installed on this system.${a.reset}`),console.log(`${a.bold}\u{1F449} To proceed, please either:${a.reset}`),console.log(" 1. Install Homebrew by running the following command in your terminal:"),console.log(` ${a.cyan}/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"${a.reset}`),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
|
|
55
55
|
`),process.exit(1)):(console.log(`
|
|
56
|
-
\u274C ${
|
|
57
|
-
`),process.exit(1))}else console.log(`\u2714 ${
|
|
58
|
-
${
|
|
59
|
-
\u{1F4E5} ${
|
|
60
|
-
\u26A0\uFE0F ${
|
|
61
|
-
${
|
|
62
|
-
\u2714 ${
|
|
63
|
-
${
|
|
64
|
-
`),await
|
|
65
|
-
${
|
|
66
|
-
`)}async function
|
|
67
|
-
${
|
|
68
|
-
`),await
|
|
56
|
+
\u274C ${a.red}Please install or update Node.js to v18+ using your system's package manager.${a.reset}
|
|
57
|
+
`),process.exit(1))}else console.log(`\u2714 ${a.green}Node.js version (v${e}) is sufficient.${a.reset}`)}W();async function go(){console.log(`
|
|
58
|
+
${a.dim}Step 2/4: Checking Vercel CLI...${a.reset}`);let e="vercel",o=!1;if(fe("vercel"))console.log(`\u2714 ${a.green}Vercel CLI is installed!${a.reset}`);else{console.log(`\u2753 ${a.yellow}Vercel CLI was not found on your system.${a.reset}`);let t=await pe("\u{1F449} Would you like to install Vercel CLI globally? (Y/n): ");t.toLowerCase()==="y"||t===""?(console.log(`
|
|
59
|
+
\u{1F4E5} ${a.cyan}Installing Vercel CLI globally... (npm install -g vercel)${a.reset}`),Te("npm",["install","-g","vercel"])&&fe("vercel")?console.log(`\u2714 ${a.green}Vercel CLI installed successfully!${a.reset}`):(console.log(`
|
|
60
|
+
\u26A0\uFE0F ${a.yellow}Global installation failed or permissions restricted.${a.reset}`),console.log(`\u2139 ${a.dim}Falling back: Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)):(console.log(`\u2139 ${a.dim}Skipping global installation. Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)}return{vercelCmd:e,useNpx:o}}var uo=require("child_process");W();var ht={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function mo(e){console.log(`
|
|
61
|
+
${a.dim}Step 3/4: Checking Vercel Login...${a.reset}`);let o=!!process.env.VERCEL_TOKEN,t=!1;if(o)console.log(`\u2714 ${a.green}VERCEL_TOKEN environment variable detected. Skipping login check.${a.reset}`),t=!0;else try{(0,uo.execSync)(e?"npx --yes vercel whoami":"vercel whoami",ht),t=!0,console.log(`\u2714 ${a.green}Logged in!${a.reset}`)}catch{t=!1}if(!t){console.log(`\u{1F511} ${a.yellow}Not logged in to Vercel.${a.reset}`),await pe("\u{1F449} Press [Enter] to login to Vercel... ");let n=["login"],i=e?"npx":"vercel",r=e?["--yes","vercel",...n]:n;if(await _e(i,r)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
|
|
62
|
+
\u2714 ${a.green}Logged in successfully!${a.reset}`)}return o}W();async function yo(e,o){console.log(`
|
|
63
|
+
${a.dim}Step 4/4: Deploying project to production...${a.reset}`);let t=["--prod","--yes"];o&&t.push("--token",process.env.VERCEL_TOKEN);let n=e?"npx":"vercel",i=e?["--yes","vercel",...t]:t;if(console.log(`${a.cyan}\u26A1 Running deployment in: ${process.cwd()}${a.reset}
|
|
64
|
+
`),await _e(n,i)!==0)throw new Error("Vercel deployment failed.");console.log(`
|
|
65
|
+
${a.bold}${a.green}\u{1F389} Deployment completed successfully!${a.reset}
|
|
66
|
+
`)}async function ho(){console.log(`
|
|
67
|
+
${a.bold}${a.cyan}\u{1F680} Starting CFM Vercel Deployment...${a.reset}
|
|
68
|
+
`),await po();let{vercelCmd:e,useNpx:o}=await go(),t=await mo(o);await yo(o,t)}var Ie=E(require("http")),j=E(require("fs")),D=E(require("path"));W();function z(e){return e instanceof Error?e.message:String(e)}Ae();var _=E(require("fs")),N=E(require("path"));W();Me();var g=E(require("fs")),p=E(require("path")),No=require("child_process");Me();function se(e,o){if(g.existsSync(e)){g.mkdirSync(o,{recursive:!0});for(let t of g.readdirSync(e,{withFileTypes:!0})){let n=p.join(e,t.name),i=p.join(o,t.name);t.isDirectory()?se(n,i):g.copyFileSync(n,i)}}}function Ye(e){let o=[],t=e;for(let n=0;n<6;n++){let i=p.join(t,"node_modules");g.existsSync(i)&&o.push(i);let r=p.dirname(t);if(r===t)break;t=r}return o}function At(e,o){let t=Ye(e);for(let n of t)for(let i of["@explorer02/cfm-survey-sdk","@repo/sdk"])for(let r of["mjs","js"]){let s=p.join(n,i,"dist",`index.${r}`);if(g.existsSync(s))return s}for(let n of["mjs","js"]){let i=p.join(o,"dist",`index.${n}`);if(g.existsSync(i))return i}throw new Error("Could not resolve @explorer02/cfm-survey-sdk for preview build")}function Et(e,o){let t=[...Ye(o).map(n=>p.join(n,"vite","bin","vite.js")),p.join(e,"node_modules","vite","bin","vite.js")];for(let n of t)if(g.existsSync(n))return n;throw new Error("Vite is required for agent preview builds. Install vite in the project or SDK package.")}function kt(e){let o=p.join(e,"src","components");if(!g.existsSync(p.join(o,"Question.tsx")))throw new Error(`Missing src/components/Question.tsx in ${e}. Build the survey UI before export-previews.`);let t=p.join(e,"src","lib"),n=p.join(e,"public");return{componentsDir:o,libDir:g.existsSync(t)?t:void 0,publicDir:g.existsSync(n)?n:void 0}}function Ft(e,o,t){let n=p.join(e,"templates","docs","templates"),i=p.join(o,"agent","src","lib");g.mkdirSync(i,{recursive:!0});let r=p.join(n,"uiConfig.ts");if(!g.existsSync(r))throw new Error(`Missing template uiConfig.ts at ${r}`);g.copyFileSync(r,p.join(i,"uiConfig.ts"));let s=p.join(o,"agent","survey-ui-config.json"),c=p.join(t,"survey-ui-config.json");g.existsSync(c)?g.copyFileSync(c,s):g.existsSync(s)||g.writeFileSync(s,JSON.stringify({version:"1.0",global:{},questionTypes:{},placeholders:{}},null,2))}function Pt(e,o,t){let n=p.join(e,"templates","docs","templates"),i=p.join(o,"agent","src","components"),r=p.join(o,"agent","src","lib","surveyUi");g.mkdirSync(r,{recursive:!0});let s=["Question.tsx","RatingScale.tsx","LikertMatrixScale.tsx","CsatMatrixScale.tsx","SliderMatrixScale.tsx","CustomSliderTrack.tsx","MatrixDropdown.tsx","FileUploadScale.tsx","HeatmapScale.tsx","RankOrderScale.tsx","surveyUiScaleUtils.ts","surveyUiIcons.tsx","Header.tsx","ProgressBar.tsx","Footer.tsx","LanguageSelector.tsx","SurveyStickyChrome.tsx"];for(let y of s){let m=p.join(n,y);g.existsSync(m)&&g.copyFileSync(m,p.join(i,y))}let c=["selectionStyles.ts","labelStyles.ts","heatmapCoords.ts"];for(let y of c){let m=p.join(n,y);g.existsSync(m)&&g.copyFileSync(m,p.join(r,y))}let d=p.join(n,"heatmapCoords.ts");g.existsSync(d)&&g.copyFileSync(d,p.join(i,"heatmapCoords.ts")),Ft(e,o,t)}function It(e){let o=`import React from 'react';
|
|
69
69
|
import { mountPreview } from '../mount';
|
|
70
70
|
`;switch(e){case"header":return`${o}import Header from '@/components/Header';
|
|
71
71
|
import ProgressBar from '@/components/ProgressBar';
|
|
@@ -86,7 +86,7 @@ mountPreview(<Footer />);`;default:return`${o}import { QuestionPreview } from '.
|
|
|
86
86
|
import { PREVIEW_FIXTURES } from '../fixtures/questions';
|
|
87
87
|
const question = PREVIEW_FIXTURES[${JSON.stringify(e)}];
|
|
88
88
|
if (!question) throw new Error('Missing fixture for ${e}');
|
|
89
|
-
mountPreview(<QuestionPreview question={question} />);`}}function
|
|
89
|
+
mountPreview(<QuestionPreview question={question} />);`}}function jt(e,o,t,n){let i=At(o,t),r=n.map(c=>` '${c}': path.resolve(workDir, '${c}', 'index.html'),`).join(`
|
|
90
90
|
`),s=`import path from 'path';
|
|
91
91
|
import { fileURLToPath } from 'url';
|
|
92
92
|
import { defineConfig } from 'vite';
|
|
@@ -106,8 +106,8 @@ export default defineConfig({
|
|
|
106
106
|
'@': path.join(workDir, 'agent', 'src'),
|
|
107
107
|
'next/image': path.join(workDir, 'stubs', 'next-image.tsx'),
|
|
108
108
|
'next/dynamic': path.join(workDir, 'stubs', 'next-dynamic.tsx'),
|
|
109
|
-
'@explorer02/cfm-survey-sdk': ${JSON.stringify(
|
|
110
|
-
'@repo/sdk': ${JSON.stringify(
|
|
109
|
+
'@explorer02/cfm-survey-sdk': ${JSON.stringify(i)},
|
|
110
|
+
'@repo/sdk': ${JSON.stringify(i)},
|
|
111
111
|
},
|
|
112
112
|
dedupe: ['react', 'react-dom'],
|
|
113
113
|
},
|
|
@@ -116,43 +116,47 @@ export default defineConfig({
|
|
|
116
116
|
emptyOutDir: true,
|
|
117
117
|
rollupOptions: {
|
|
118
118
|
input: {
|
|
119
|
-
${
|
|
119
|
+
${r}
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
|
-
`;
|
|
125
|
-
</
|
|
126
|
-
|
|
124
|
+
`;g.writeFileSync(p.join(e,"vite.config.mjs"),s)}function Nt(e,o,t){let n=g.readFileSync(e,"utf8"),i=!1;if(!n.includes("cfm-preview-fonts")&&t&&n.includes("</head>")&&(n=n.replace("</head>",`${t}
|
|
125
|
+
</head>`),i=!0),!n.includes("CFM_UI_CONFIG_SNAPSHOT")){let r=`<script>${o}</script>`;n=n.includes("</body>")?n.replace("</body>",`${r}
|
|
126
|
+
</body>`):`${n}
|
|
127
|
+
${r}`,i=!0}i&&g.writeFileSync(e,n)}function _t(e){return e.replace(/_/g," ")}async function _o(e){let{projectRoot:o,outputDir:t,keys:n}=e,i=p.join(__dirname,"..",".."),r=p.join(i,"templates","preview-harness","vite-app");if(!g.existsSync(r))throw new Error(`Missing Vite preview harness template at ${r}`);let s=kt(o),c=p.join(t,".preview-vite-work");g.existsSync(c)&&g.rmSync(c,{recursive:!0,force:!0}),se(r,c),g.mkdirSync(p.join(c,"agent","src"),{recursive:!0}),se(s.componentsDir,p.join(c,"agent","src","components")),s.libDir&&se(s.libDir,p.join(c,"agent","src","lib")),s.publicDir&&se(s.publicDir,p.join(c,"agent","public")),Pt(i,c,o);let d=p.join(o,"survey-ui-config.json");g.existsSync(d)&&g.copyFileSync(d,p.join(c,"agent","survey-ui-config.json"));let y=ge(o),m=p.join(c,"src","survey-theme.css");g.writeFileSync(m,y?g.readFileSync(y,"utf8"):g.readFileSync(p.join(i,"templates","survey-theme.css"),"utf8")),g.mkdirSync(p.join(c,"src","entries"),{recursive:!0});for(let I of n)g.mkdirSync(p.join(c,I),{recursive:!0}),g.writeFileSync(p.join(c,I,"index.html"),`<!DOCTYPE html>
|
|
127
128
|
<html lang="en">
|
|
128
129
|
<head>
|
|
129
130
|
<meta charset="UTF-8" />
|
|
130
131
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
131
|
-
<title>${_t(
|
|
132
|
+
<title>${_t(I)} \u2014 CFM Preview</title>
|
|
133
|
+
<link id="cfm-preview-fonts" rel="preconnect" href="https://fonts.googleapis.com" />
|
|
134
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
135
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto:wght@400;500;600;700&family=Open+Sans:wght@400;500;600;700&family=Lato:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&family=Nunito:wght@400;500;600;700&family=Raleway:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&family=Merriweather:wght@400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap" />
|
|
132
136
|
</head>
|
|
133
137
|
<body>
|
|
134
138
|
<div id="root"></div>
|
|
135
|
-
<script type="module" src="../src/entries/${
|
|
139
|
+
<script type="module" src="../src/entries/${I}.tsx"></script>
|
|
136
140
|
</body>
|
|
137
|
-
</html>`),
|
|
138
|
-
${
|
|
139
|
-
${
|
|
140
|
-
`),dn(
|
|
141
|
-
${
|
|
142
|
-
`),
|
|
143
|
-
`));let
|
|
144
|
-
${
|
|
145
|
-
`),
|
|
146
|
-
${
|
|
147
|
-
${
|
|
148
|
-
`);try{await
|
|
149
|
-
${
|
|
150
|
-
${
|
|
151
|
-
${
|
|
152
|
-
${
|
|
153
|
-
${
|
|
154
|
-
${
|
|
155
|
-
${
|
|
156
|
-
${
|
|
157
|
-
${
|
|
141
|
+
</html>`),g.writeFileSync(p.join(c,"src","entries",`${I}.tsx`),It(I));g.writeFileSync(p.join(c,"tsconfig.json"),JSON.stringify({compilerOptions:{target:"ES2020",lib:["ES2020","DOM","DOM.Iterable"],module:"ESNext",moduleResolution:"bundler",jsx:"react-jsx",strict:!0,skipLibCheck:!0,paths:{"@/*":["./agent/src/*"]}},include:["src","agent/src","stubs"]},null,2)),jt(c,o,i,n);let b=Et(i,o),x=Ye(o).join(p.delimiter);(0,No.execSync)(`node "${b}" build --config "${p.join(c,"vite.config.mjs")}"`,{cwd:c,stdio:"inherit",env:{...process.env,NODE_PATH:x}});let A=p.join(t,"previews");g.mkdirSync(A,{recursive:!0});let F=p.join(c,"dist"),R=g.readFileSync(p.join(i,"templates","preview-harness","preview-bridge.inline.js"),"utf8"),S=g.readFileSync(p.join(i,"templates","preview-harness","preview-google-fonts.html"),"utf8").trim();for(let I of n){let u=p.join(F,I),C=p.join(A,I);if(!g.existsSync(p.join(u,"index.html")))throw new Error(`Vite build did not produce ${I}/index.html`);g.existsSync(C)&&g.rmSync(C,{recursive:!0,force:!0}),se(u,C),Nt(p.join(C,"index.html"),R,S)}let f=p.join(F,"assets");g.existsSync(f)&&se(f,p.join(A,"assets"));let P=p.join(c,"agent","public");if(g.existsSync(P))for(let I of g.readdirSync(P)){let u=p.join(P,I);g.statSync(u).isFile()&&g.copyFileSync(u,p.join(A,I))}g.rmSync(c,{recursive:!0,force:!0})}var Ze=E(require("fs")),eo=E(require("path"));function Oe(e){if(e)return e;let o=process.cwd();if(Ze.existsSync(eo.join(o,"src","components","Question.tsx")))return o;let t=process.env.INIT_CWD;return t&&Ze.existsSync(eo.join(t,"src","components","Question.tsx"))?t:o}var vo=["header","footer","survey_page"],Do={MCQ:["MCQ_single","MCQ_multiple"],TEXTFIELD:["TEXTFIELD_short","TEXTFIELD_long"],NPS_SCALE:["NPS_SCALE"],CFM_MATRIX:["CFM_likert","CFM_bipolar"],TEXT_AND_MEDIA:["TEXT_AND_MEDIA"],CSAT_MATRIX:["CSAT_emoji","CSAT_star","CSAT_numbered","CSAT_graphics"],RATING_MATRIX:["RATING_star","RATING_numbered","RATING_radio","RATING_emoji","RATING_graphics"],SLIDER_MATRIX:["SLIDER_matrix"],FILE_UPLOAD:["FILE_UPLOAD"],HEATMAP:["HEATMAP"],RANK_ORDER:["RANK_drag","RANK_dropdown"]},fi=[...vo,...Object.values(Do).flat()];function Lo(e){let o=new Set(vo);for(let t of e)for(let n of Do[t]??[])o.add(n);return[...o]}var U=a;function vt(){return N.join(__dirname,"..","..","templates")}function Dt(e){let o=_.readFileSync(e,"utf8"),t=new Set,n=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];for(let i of n)o.includes(i)&&t.add(i);return t.size?[...t]:n}function Lt(e,o){let t=new Set(Lo(o));return e.filter(n=>t.has(n))}function oo(e,o,t){if(_.existsSync(e))for(let n of _.readdirSync(e)){let i=N.join(e,n),r=N.posix.join(o,n);if(_.statSync(i).isDirectory())oo(i,r,t);else{let s=N.extname(n).toLowerCase(),c=s===".html"?"text/html":s===".css"?"text/css":s===".js"?"application/javascript":s===".json"?"application/json":s===".svg"?"image/svg+xml":s===".jpg"||s===".jpeg"?"image/jpeg":s===".png"?"image/png":"application/octet-stream";t.push({path:r,contentType:c,sizeBytes:_.statSync(i).size})}}}async function ye(e={}){let o=Oe(e.projectRoot),t=e.outputDir??N.join(o,"out"),n=vt(),i=N.join(n,"preview-harness");e.useTemplatesOnly&&console.log(`${U.dim} Using SDK template preview harness only (--use-templates-only)${U.reset}`);let r=N.join(i,"previewPages.js"),{PREVIEW_PAGE_DEFS:s,buildPreviewHtml:c,PREVIEW_KEYS:d}=require(r),y=(()=>{let f=ge(o);return f?(console.log(`${U.dim} Using project theme: ${N.relative(o,f)}${U.reset}`),_.readFileSync(f,"utf8")):_.readFileSync(N.join(n,"survey-theme.css"),"utf8")})(),m=_.readFileSync(N.join(i,"preview-bridge.inline.js"),"utf8"),b=_.readFileSync(N.join(i,"preview-google-fonts.html"),"utf8").trim(),x=e.surveyTypes;if(!x){let f=N.join(o,"implementation_plan.md");x=_.existsSync(f)?Dt(f):["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]}let A=Lt(d,x),F=N.join(t,"previews");if(_.existsSync(F)&&(_.rmSync(F,{recursive:!0,force:!0}),console.log(`${U.dim} Cleared previous preview output${U.reset}`)),_.mkdirSync(F,{recursive:!0}),!e.useTemplatesOnly)try{console.log(`${U.dim} Building previews from agent components (Vite)\u2026${U.reset}`),await _o({projectRoot:o,outputDir:t,keys:A});let f={};for(let I of A)f[I]=`previews/${I}/index.html`;_.writeFileSync(N.join(t,"previews","manifest.json"),JSON.stringify(f,null,2));let P=[];return oo(N.join(t,"previews"),"previews",P),console.log(`${U.green}\u2705 Exported ${A.length} agent component previews \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:N.join(t,"previews","manifest.json"),files:P,surveyTypes:x}}catch(f){console.warn(`${U.yellow}\u26A0 Agent Vite preview build failed; falling back to template harness.${U.reset}`),console.warn(`${U.dim} ${z(f)}${U.reset}`)}for(let f of s){if(!A.includes(f.key))continue;let P=N.join(t,"previews",f.key);_.mkdirSync(P,{recursive:!0}),_.writeFileSync(N.join(P,"index.html"),c(f,y,m,b))}let R={};for(let f of A)R[f]=`previews/${f}/index.html`;_.writeFileSync(N.join(t,"previews","manifest.json"),JSON.stringify(R,null,2));let S=[];return oo(N.join(t,"previews"),"previews",S),console.log(`${U.green}\u2705 Exported ${A.length} preview pages \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:N.join(t,"previews","manifest.json"),files:S,surveyTypes:x}}var v=a,Pe=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];function Ko(e){return new Promise(o=>{let t=Ie.createServer();t.listen(e,()=>{t.close(()=>o(e))}),t.on("error",()=>o(Ko(e+1)))})}function Qo(e){return new Promise((o,t)=>{let n="";e.on("data",i=>n+=i),e.on("end",()=>o(n)),e.on("error",t)})}function dn(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function so(e){let o=D.extname(e).toLowerCase();return{".html":"text/html",".js":"application/javascript",".css":"text/css",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".woff2":"font/woff2",".ico":"image/x-icon"}[o]??"application/octet-stream"}function fn(e){let o=new Set,t,n=e.match(/\*\*instanceId:\*\*\s*(.+)/i);if(n){let r=n[1].replace(/[()[\]]/g,"").trim();r&&!r.startsWith("(")&&r!=="JWT"&&(t=r)}for(let r of Pe)e.includes(r)&&o.add(r);let i=e.matchAll(/\|\s*`([A-Z_]+)`\s*\|/g);for(let r of i)Pe.includes(r[1])&&o.add(r[1]);return{surveyTypes:o.size>0?[...o]:[...Pe],instanceId:t}}async function pn(e){return new Promise(o=>{try{let t=Ie.get(e,n=>{o((n.statusCode??500)<500),n.resume()});t.on("error",()=>o(!1)),t.setTimeout(2e3,()=>{t.destroy(),o(!1)})}catch{o(!1)}})}function co(e){let o=D.join(e,"out","previews");j.existsSync(o)&&(j.rmSync(o,{recursive:!0,force:!0}),console.log(`${v.dim} Removed local preview files: out/previews/${v.reset}`))}async function Yo(){let e=process.env.INIT_CWD||process.cwd(),o=D.join(e,"public"),t=D.join(e,"survey-ui-config.json"),n=D.join(e,"implementation_plan.md"),i=D.join(__dirname,"..","..","templates"),r=D.join(i,"wizard-dist"),s=process.env.CFM_PREVIEW_URL??"http://localhost:3000",c={},d=D.join(e,"out","previews"),y=D.join(d,"manifest.json");console.log(`${v.dim} Exporting component previews for local wizard\u2026${v.reset}`),await ye({projectRoot:e,surveyTypes:[...Pe]}),j.existsSync(y)&&(c=JSON.parse(j.readFileSync(y,"utf8")));let m=await Ko(4200),b=`http://localhost:${m}`;return new Promise((x,A)=>{let F=Ie.createServer(async(S,f)=>{try{let P=S.url??"/",I=P.split("?")[0];if(S.method==="GET"&&I.startsWith("/api/project-logo/")){let u=D.basename(decodeURIComponent(I.slice(18))),C=D.join(o,u),T=D.normalize(C);if(T.startsWith(o)&&j.existsSync(T)&&j.statSync(T).isFile()){let $=j.readFileSync(T);f.writeHead(200,{"Content-Type":so(T)}),f.end($);return}f.writeHead(404),f.end("Logo not found");return}if(S.method==="GET"&&I==="/api/inventory"){let u;if(j.existsSync(n)){let $=j.readFileSync(n,"utf8");u=fn($).instanceId}if(j.existsSync(t))try{let $=JSON.parse(j.readFileSync(t,"utf8"));$.instanceId&&(u=$.instanceId)}catch{}let C=[...Pe],{config:T}=me({projectRoot:e,surveyTypes:C,instanceId:u});f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({surveyTypes:C,instanceId:u,previewUrl:s,initialConfig:T,previewManifest:Object.fromEntries(Object.keys(c).map($=>[$,`${b}/previews/${$}/index.html`]))}));return}if(S.method==="GET"&&P==="/api/preview-url"){let u=await pn(s);f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({url:s,connected:u}));return}if(S.method==="POST"&&P.split("?")[0]==="/api/wizard-quit"){co(e),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({ok:!0,deleted:"out/previews"})),setTimeout(()=>{F.close(()=>{A(new Error("Client quit the wizard without saving. Local preview garbage collection complete (out/previews removed)."))})},300);return}if(S.method==="POST"&&P==="/api/upload-logo"){let u=await Qo(S),C=JSON.parse(u);j.existsSync(o)||j.mkdirSync(o,{recursive:!0});let T=C.base64.replace(/^data:image\/\w+;base64,/,""),$=Buffer.from(T,"base64"),J=D.extname(C.filename),G=D.basename(C.filename,J).toLowerCase().replace(/[^a-z0-9_-]/g,""),de=`logo_${Date.now()}_${G}${J||".png"}`;j.writeFileSync(D.join(o,de),$),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({fileName:de}));return}if(S.method==="POST"&&P==="/api/save-config"){let u=await Qo(S),C=JSON.parse(u);C.configuredAt=new Date().toISOString();let T=C.global?.logo;T?.url?.startsWith("data:")&&(T.url=null),j.writeFileSync(t,JSON.stringify(C,null,2),"utf8"),console.log(`
|
|
142
|
+
${v.green}\u2705 UI configuration saved to ${t}${v.reset}`);try{let{runApplyUiConfig:$}=await Promise.resolve().then(()=>(Fe(),ke));$({projectRoot:e,configPath:t})}catch($){console.log(`${v.yellow} CSS apply skipped: ${$ instanceof Error?$.message:String($)}${v.reset}`)}co(e),console.log(`${v.dim} Local preview garbage collection complete (out/previews removed)${v.reset}`),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({ok:!0})),setTimeout(()=>{F.close(()=>x())},500);return}if(S.method==="GET"){let u=P.split("?")[0];if(u==="/"&&(u="/index.html"),u.startsWith("/previews/")&&j.existsSync(d)){let $=u.replace(/^\/previews\//,""),J=D.join(d,$),G=D.normalize(J);if(G.startsWith(d)&&j.existsSync(G)&&j.statSync(G).isFile()){let de=j.readFileSync(G);f.writeHead(200,{"Content-Type":so(G)}),f.end(de);return}}let C=j.existsSync(r),T=C?D.join(r,u):D.join(i,"wizard.html");if(C&&j.existsSync(T)&&j.statSync(T).isFile()){let $=j.readFileSync(T);f.writeHead(200,{"Content-Type":so(T)}),f.end($);return}if(!C&&u==="/index.html"){let $=j.readFileSync(D.join(i,"wizard.html"),"utf8");f.writeHead(200,{"Content-Type":"text/html"}),f.end($);return}}f.writeHead(404,{"Content-Type":"text/plain"}),f.end("Not found")}catch(P){f.writeHead(500,{"Content-Type":"text/plain"}),f.end(`Server error: ${z(P)}`)}});F.listen(m,()=>{let S=b;console.log(`
|
|
143
|
+
${v.bold}${v.cyan}\u{1F3A8} Survey UI Customization Wizard${v.reset}`),console.log(`${v.bold}\u{1F517} Client wizard link \u2014 share this URL only:${v.reset}`),console.log(` ${v.green}${S}${v.reset}`),console.log(`${v.dim} Port ${m} (auto-selected if 4200 was in use)${v.reset}`),console.log(`${v.dim} Live previews: ${v.reset}${Object.keys(c).length} components`),console.log(`${v.dim} Preview target: ${v.reset}${s}`),console.log(`${v.dim} Default wizard \u2014 saves directly to survey-ui-config.json when client clicks Review & Build${v.reset}
|
|
144
|
+
`),dn(S)}),F.on("error",A);let R=()=>{co(e),F.close(()=>process.exit(130))};process.once("SIGINT",R),process.once("SIGTERM",R)})}var Se=E(require("fs")),tt=E(require("path")),nt=E(require("http")),it=E(require("https"));W();xe();Ae();Ee();He();var h=a;function un(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function mn(e){return new Promise(o=>setTimeout(o,e))}async function lo(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?it:nt).request(i,{method:o.method??"GET",headers:o.headers??{}},c=>{let d="";c.on("data",y=>d+=y),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),o.body&&s.write(o.body),s.end()})}async function yn(e,o,t,n){return new Promise((i,r)=>{let s=new URL(e),c=s.protocol==="https:"?it:nt,d={"Content-Type":t,"Content-Length":o.length};n&&(d["X-Wizard-Session"]=n.sessionSecret,d["X-Wizard-Session-Id"]=n.sessionId);let y=c.request(s,{method:"PUT",headers:d},m=>{if((m.statusCode??500)>=400){let b="";m.on("data",x=>b+=x),m.on("end",()=>r(new Error(`PUT failed ${m.statusCode}: ${b}`)));return}m.resume(),i()});y.on("error",r),y.write(o),y.end()})}function hn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function rt(e={}){let o=e.wait!==!1,t=e.pollIntervalMs??Number(process.env.CFM_WIZARD_POLL_MS??3e3),n=e.timeoutMs??Number(process.env.CFM_WIZARD_TIMEOUT_MS??72e5),i=process.env.CFM_INSTANCE_ID,r=(process.env.CFM_DEPLOY_API_BASE??"http://localhost:3000").replace(/\/$/,"");if(!i)throw new Error("CFM_INSTANCE_ID (JWT) is required");let s=hn(i);if(!s)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let c=Oe(),d=ie(c),y=d.activeConfigPath,m=e.apply?!1:e.review!==!1;console.log(`
|
|
145
|
+
${h.bold}${h.cyan}\u{1F3A8} CFM UI Customization (AWS)${h.reset}
|
|
146
|
+
`),m&&(console.log(`${h.dim} Review mode: seed kept in survey-ui-config.json; final + diff written on complete.${h.reset}`),console.log(`${h.dim} Apply later with: npx cfm-sdk confirm-ui-config${h.reset}
|
|
147
|
+
`));let b=[...Q],{outputDir:x,files:A}=await ye({projectRoot:c,useTemplatesOnly:e.useTemplatesOnly,surveyTypes:b}),F=A.map(u=>({path:u.path,contentType:u.contentType,sizeBytes:u.sizeBytes})),{config:R,source:S}=me({projectRoot:c,surveyTypes:b,instanceId:s});R.surveyTypes=b,Qe(S),m&&(Se.writeFileSync(d.seedPath,JSON.stringify(R,null,2),"utf8"),Se.writeFileSync(y,JSON.stringify(R,null,2),"utf8"),console.log(`${h.dim} Seed snapshot \u2192 survey-ui-config.json (+ .seed.json)${h.reset}`));let f=await lo(`${r}/wizard/session/start`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({files:F,surveyTypes:b,initialConfig:R})});console.log(`${h.dim} Uploading ${F.length} preview files\u2026${h.reset}`);for(let u of f.uploads){let C=tt.join(x,u.path),T=Se.readFileSync(C),$=F.find(J=>J.path===u.path)?.contentType??"application/octet-stream";await yn(u.uploadUrl,T,$,{sessionId:f.sessionId,sessionSecret:f.sessionSecret})}if(await lo(`${r}/wizard/previews/upload/complete`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:f.sessionId})}),console.log(`${h.green}\u2705 Previews uploaded${h.reset}`),console.log(`${h.dim} ${F.length} component preview page(s) \u2192 EC2 local server (disk)${h.reset}`),console.log(`
|
|
148
|
+
${h.bold}${h.cyan}\u{1F517} Client wizard link \u2014 share with the client:${h.reset}`),console.log(`${h.green} ${f.wizardUrl}${h.reset}`),console.log(`${h.dim} (Deployed on EC2 \u2014 client customizes here; agent keeps CLI open until submit)${h.reset}
|
|
149
|
+
`),un(f.wizardUrl),!o){console.log(`${h.yellow}--no-wait: wizard URL (not polling):${h.reset}`),console.log(f.wizardUrl),m&&console.log(`${h.dim} When wizard completes, poll manually or re-run without --no-wait to capture final + diff.${h.reset}`);return}let P=Date.now()+n,I=0;for(;Date.now()<P;){I+=1,process.stdout.write(`\r${h.dim}Waiting for client to finish wizard\u2026 (poll ${I})${h.reset}`);let u=await lo(`${r}/wizard/config/${encodeURIComponent(s)}?sessionId=${f.sessionId}`,{headers:{Authorization:`Bearer ${i}`}});if(u.status==="abandoned")throw console.log(`
|
|
150
|
+
${h.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${h.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(u.status==="ready"&&u.config){let C=Xe(u)??u.config;if(console.log(`
|
|
151
|
+
${h.green}\u2705 Configuration ready${h.reset}`),u.logoUrl&&console.log(`${h.dim} Logo URL: ${u.logoUrl}${h.reset}`),m){let J=We(c,R,C);console.log(`${h.green} Seed (unchanged active): ${y}${h.reset}`),console.log(`${h.green} Final: ${d.finalPath}${h.reset}`),console.log(`${h.green} Diff: ${d.diffMdPath}${h.reset}`),console.log(`${h.yellow} ${J.changed.length} changed, ${J.added.length} added, ${J.removed.length} removed${h.reset}`);let G=C.global?.logo;if(G?.fileName)try{await le({projectRoot:c,fileName:G.fileName,logoUrl:u.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${h.green} Logo saved to public/${G.fileName}${h.reset}`)}catch(de){console.warn(`${h.yellow} Logo download deferred: ${z(de)}${h.reset}`)}console.log(`${h.dim} Apply when ready: npx cfm-sdk confirm-ui-config (promotes JSON + regenerates survey-theme.css)${h.reset}`);return}Se.writeFileSync(y,JSON.stringify(C,null,2),"utf8"),console.log(`${h.green} Written ${y}${h.reset}`);let{runApplyUiConfig:T}=await Promise.resolve().then(()=>(Fe(),ke));T({projectRoot:c,configPath:y});let $=C.global?.logo;$?.fileName&&(await le({projectRoot:c,fileName:$.fileName,logoUrl:u.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${h.green} Logo saved to public/${$.fileName}${h.reset}`));return}await mn(t)}throw new Error("Timed out waiting for wizard completion")}Ae();W();var M=a,re=process.argv.slice(2),ee=re[0];async function Rn(){if(ee==="customize"||ee==="init"){ee==="init"&&console.log(`${M.yellow}\u26A0 cfm-sdk init is deprecated. Use \`cfm-sdk customize\` instead.${M.reset}
|
|
152
|
+
`);try{await Yo()}catch(e){console.error(`
|
|
153
|
+
${M.red}\u274C Error: ${z(e)}${M.reset}`),process.exit(1)}}else if(ee==="customize-ui"){let e=re.includes("--use-templates-only"),o=re.includes("--no-wait"),t=re.includes("--apply"),n=re.includes("--no-review")?!1:!t;try{await rt({useTemplatesOnly:e,wait:!o,review:n,apply:t})}catch(i){console.error(`
|
|
154
|
+
${M.red}\u274C Error: ${z(i)}${M.reset}`),process.exit(1)}}else if(ee==="confirm-ui-config"){let e=re.includes("--diff-only");try{let{runConfirmUiConfig:o}=await Promise.resolve().then(()=>(ct(),st));await o({diffOnly:e})}catch(o){console.error(`
|
|
155
|
+
${M.red}\u274C Error: ${z(o)}${M.reset}`),process.exit(1)}}else if(ee==="apply-ui-config")try{let{runApplyUiConfig:e}=await Promise.resolve().then(()=>(Fe(),ke));e({})}catch(e){console.error(`
|
|
156
|
+
${M.red}\u274C Error: ${z(e)}${M.reset}`),process.exit(1)}else if(ee==="fetch-ui-config"){let o=re.find(t=>t.startsWith("--session="))?.split("=")[1];try{let{runFetchUiConfig:t}=await Promise.resolve().then(()=>(lt(),at));await t({sessionId:o})}catch(t){console.error(`
|
|
157
|
+
${M.red}\u274C Error: ${z(t)}${M.reset}`),process.exit(1)}}else if(ee==="export-previews"){let e=re.includes("--use-templates-only");try{await ye({useTemplatesOnly:e})}catch(o){console.error(`
|
|
158
|
+
${M.red}\u274C Error: ${z(o)}${M.reset}`),process.exit(1)}}else if(ee==="resolve-ui-config"){let e=re.includes("--write");try{if(e){let o=Ke();console.log(`${M.green}\u2705 Wrote ${o}${M.reset}`)}else{let{resolveInitialConfig:o}=await Promise.resolve().then(()=>(Ae(),jo)),{config:t,source:n}=o({surveyTypes:[]});console.log(JSON.stringify({source:n,config:t},null,2))}}catch(o){console.error(`
|
|
159
|
+
${M.red}\u274C Error: ${z(o)}${M.reset}`),process.exit(1)}}else if(ee==="deploy")try{await ho()}catch(e){console.error(`
|
|
160
|
+
${M.red}\u274C Error: ${z(e)}${M.reset}`),process.exit(1)}else console.log(`
|
|
161
|
+
${M.bold}${M.cyan}CFM SDK CLI Tool${M.reset}`),console.log(`
|
|
158
162
|
Usage:`),console.log(" npx cfm-sdk customize \u2013 Local UI customization wizard"),console.log(" npx cfm-sdk customize-ui \u2013 AWS wizard (review mode: seed + diff, no auto-apply)"),console.log(" npx cfm-sdk customize-ui --apply \u2013 AWS wizard (legacy: write final config immediately)"),console.log(" npx cfm-sdk confirm-ui-config \u2013 Promote final config + apply CSS to project"),console.log(" npx cfm-sdk apply-ui-config \u2013 Regenerate survey-theme.css from survey-ui-config.json"),console.log(" npx cfm-sdk fetch-ui-config \u2013 Pull final + diff after client completes (--no-wait)"),console.log(" npx cfm-sdk export-previews \u2013 Build component preview pages only"),console.log(" npx cfm-sdk resolve-ui-config --write \u2013 Write draft survey-ui-config.json from project"),console.log(" npx cfm-sdk deploy \u2013 Deploy to Vercel"),process.exit(0)}Rn();
|