@explorer02/cfm-survey-sdk 0.4.0 → 0.4.1
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 +64 -64
- package/dist/cli/index.mjs +63 -63
- package/package.json +1 -1
- package/templates/docs/templates/CsatMatrixScale.tsx +79 -23
- package/templates/docs/templates/Footer.tsx +3 -2
- package/templates/docs/templates/labelStyles.ts +27 -0
- package/templates/docs/templates/uiConfig.ts +23 -8
- package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +54 -8
- 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/mergePreviewQuestion.ts +67 -7
- package/templates/preview-harness/vite-app/src/preview-live-overrides.css +8 -0
- package/templates/survey-theme.css +13 -0
- package/templates/wizard-dist/assets/{PreviewMock-BlOAvUCN.js → PreviewMock-MsONyaq9.js} +1 -1
- package/templates/wizard-dist/assets/TypePanel-D24BxbHk.js +1 -0
- package/templates/wizard-dist/assets/index-C7RSJr09.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.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var it=Object.defineProperty;var Pe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ie=(e,o)=>{for(var t in o)it(e,t,{get:o[t],enumerable:!0})};var l,q=z(()=>{"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 J,Se=z(()=>{"use strict";J=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function pt(e){let o={};for(let t of e)uo[t]&&(o[t]={...uo[t]});return o}function gt(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:{...D},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:pt(e),placeholders:{firstName:"Alex",lastName:"Customer",email:"alex@example.com"},customFields:{},debug:{enabled:!1,sampleAnswers:{}},deploy:{target:"aws",autoDeploy:!1}}}function Z(e,o){return{...e,...o??{}}}function je(e){let o=(e.surveyTypes??[]).filter(c=>J.includes(c)),t=[...new Set([...o,...J])],n=gt(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:Z(i.header,r.header),footer:Z(i.footer,r.footer),theme:Z(i.theme,r.theme),layout:Z(i.layout,r.layout),buttons:Z(i.buttons,r.buttons),logo:Z(i.logo,r.logo),colorScheme:Z(i.colorScheme,r.colorScheme),typography:Z(i.typography,r.typography),motion:Z(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 D,uo,We=z(()=>{"use strict";Se();D={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},uo={MCQ:{cardStyle:"outlined",selectedAccent:D.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:D.secondary,hoverBorderColor:D.accent},TEXTFIELD:{inputRadius:8,focusRing:D.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:D.secondary,labelColor:D.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:D.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:D.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:D.primary,cellPadding:8,accentColor:D.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:D.accent,cellSize:40,tooltipBg:"#1F2937",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:D.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:D.primary,rowLabelWidth:180,unselectedStarOpacity:.5,graphicsTrackColor:"#E5E7EB",graphicsThumbColor:D.primary},SLIDER_MATRIX:{trackColor:D.accent,thumbColor:D.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:D.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:D.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:D.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:D.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});import*as _e from"fs";import*as Te from"path";function ho(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 A(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function yo(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function Ce(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function wo(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"]&&po[e["--cfm-max-width"]]&&(c.width=po[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&go[e["--cfm-border-radius"]]&&(c.borderStyle=go[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],mo[e["--cfm-font-family"]]&&(c.fontStyle=mo[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=Ce(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let B=A(e["--cfm-motion-duration"]);B!==void 0&&(m.durationMs=B,m.enabled=B>0)}e["--cfm-header-height"]&&(r.height=A(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(r.logoBoxWidth=A(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(r.logoBoxHeight=A(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(r.logoPadding=A(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=A(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(r.companyNameFontWeight=Ce(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(r.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(r.contentPaddingX=A(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=A(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(i.logoHeight=A(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(i.paddingY=A(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(i.paddingX=A(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=A(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=A(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=A(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=A(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=A(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(S.optionGap=A(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(S.cardPadding=A(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=A(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=A(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=A(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(g.TEXTFIELD=x);let k={};e["--cfm-nps-selected-fill"]&&(k.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(k.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(k.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(k.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(k.cellSize=A(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(k.cellGap=A(e["--cfm-nps-cell-gap"])),Object.keys(k).length&&(g.NPS_SCALE=k);let E=A(e["--cfm-matrix-row-width"]),R={};E!==void 0&&(R.rowLabelWidth=E),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=yo(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&(R.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&(R.cellPadding=A(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=A(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(p.unselectedOpacity=Ce(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(p.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(p.cellSize=A(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"]),E!==void 0&&(h.rowLabelWidth=E),e["--cfm-star-unselected-opacity"]&&(h.unselectedStarOpacity=Ce(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"]),E!==void 0&&(T.rowLabelWidth=E),e["--cfm-slider-row-band"]&&(T.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(T.tickBadgeSize=A(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=A(e["--cfm-upload-padding"])),Object.keys($).length&&(g.FILE_UPLOAD=$);let b={};e["--cfm-media-max-width"]&&(b.mediaMaxWidth=yo(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(b.mediaRadius=A(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(b.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(b.captionSize=A(e["--cfm-media-caption-size"])),Object.keys(b).length&&(g.TEXT_AND_MEDIA=b);let F={};e["--cfm-heatmap-pin"]&&(F.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(F.pinSize=A(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(F.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(F.overlayOpacity=Ce(e["--cfm-heatmap-overlay-opacity"])),Object.keys(F).length&&(g.HEATMAP=F);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=A(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(C.itemGap=A(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 fe(e){let o=[Te.join(e,"src","styles","survey-theme.css"),Te.join(e,"src","app","survey-theme.css"),Te.join(e,"src","styles","globals.css"),Te.join(e,"src","app","globals.css")];for(let t of o)if(_e.existsSync(t)&&_e.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var po,go,mo,ve=z(()=>{"use strict";po={"36rem":"narrow","48rem":"standard","64rem":"wide"},go={"0px":"sharp","12px":"rounded","9999px":"pill"},mo={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});import*as De from"fs";import*as bo from"path";function yt(e){for(let o of mt){let t=bo.join(e,o);if(De.existsSync(t))return t}return null}function ht(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 So(e){let o=yt(e);if(!o)return null;let t=De.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=ht(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 mt,Co=z(()=>{"use strict";mt=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var Ao={};Ie(Ao,{logSeedSource:()=>He,resolveInitialConfig:()=>pe,writeResolvedUiConfig:()=>Ve});import*as G from"fs";import*as ee from"path";function Xe(e){return e.filter(o=>J.includes(o))}function To(e){try{let o=JSON.parse(G.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function St(e){let o={global:{}};if(!G.existsSync(e))return o;let t=G.readFileSync(e,"utf8"),n=new Set;for(let i of J)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 Ro(e,o){let t=ee.join(e,o);if(!G.existsSync(t))return null;let n=G.readFileSync(t);if(n.length>wt)return{fileName:o,dataUrl:""};let r=ee.extname(o).toLowerCase(),i=bt[r]??"application/octet-stream";return{fileName:o,dataUrl:`data:${i};base64,${n.toString("base64")}`}}function xo(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=Ro(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 $o(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 pe(e){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=ee.join(o,"survey-ui-config.json"),n=ee.join(o,"implementation_plan.md"),r=ee.join(o,"public"),i=Xe(e.surveyTypes),s={},c="defaults",d=fe(o);if(d){let C=G.readFileSync(d,"utf8"),B=ho(C);Object.keys(B).length>0&&(s=wo(B),c="survey-theme.css")}let m=St(n);s=$o(s,m);let g=To(t);g&&(s=$o(s,g),c="survey-ui-config.json");let S=ee.join(o,"survey-ui-config.final.json"),x=To(S),k=!!g?.configuredAt,E=!!x?.configuredAt;if(x&&E&&!k){let C=xo(r,x.global?.logo);C&&(s.global={...s.global??{},logo:{fileName:C.fileName,url:C.url}})}let R=xo(r,s.global?.logo),p=So(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=Ro(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=Xe(s.surveyTypes??i),s.surveyTypes?.length||(s.surveyTypes=i),e.instanceId&&(s.instanceId=e.instanceId),{config:je(s),source:c}}function He(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 Ve(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??Xe(J),{config:n}=pe({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),r=ee.join(o,"survey-ui-config.json");return G.writeFileSync(r,JSON.stringify(n,null,2),"utf8"),r}var ue,wt,bt,xe=z(()=>{"use strict";q();We();ve();Se();Co();ue=l,wt=512e3,bt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function W(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 _t(){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 vt(){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 Me(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 _o(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 Ye(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 Dt(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 Lt(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 Mt(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"),_o(e,o),Me(e,o)}function Bt(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")),Ye(e,o,"matrix")}function Ot(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"),Ye(e,o,"csat"),Me(e,o)}function Ut(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"),Ye(e,o,"rating"),Me(e,o)}function zt(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`,_o(e,o),Me(e,o)}function qt(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 Wt(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 Xt(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 Ht(e,o){let t=W(o.drag)??o,n=W(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 Be(e){let o=W(e.global)??{},t=W(o.colorScheme)??{},n=W(o.header)??{},r=W(o.footer)??{},i=W(o.theme)??{},s=W(o.layout)??{},c=W(o.typography)??{},d=W(o.motion)??{},m=e.questionTypes??{},g=a(s.fontStyle,"modern"),S=jo[g]??a(c.fontFamily,jo.modern),x=a(s.width,"standard"),k=a(s.borderStyle,"rounded"),E=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":Io[x]??Io.standard,"--cfm-border-radius":No[k]??No.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)",..._t(),"--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`,...vt(),"--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":E,"--cfm-csat-ring-color":E,"--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",Dt],["TEXTFIELD",Lt],["NPS_SCALE",Mt],["CFM_MATRIX",Bt],["CSAT_MATRIX",Ot],["RATING_MATRIX",Ut],["SLIDER_MATRIX",zt],["FILE_UPLOAD",qt],["TEXT_AND_MEDIA",Wt],["HEATMAP",Xt],["RANK_ORDER",Ht]];for(let[$,b]of T){let F=W(m[$]);F&&b(h,F)}return h}function Ze(e){let o=e.questionTypes??{},t=W(o.MCQ),n=W(o.NPS_SCALE),r=W(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 Io,No,jo,eo=z(()=>{"use strict";Io={narrow:"36rem",standard:"48rem",wide:"64rem"},No={sharp:"0px",rounded:"12px",pill:"9999px"},jo={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'}});import*as oe from"fs";import*as se from"path";function Vt(e){return`:root {
|
|
2
|
+
var rt=Object.defineProperty;var Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,o)=>()=>(e&&(o=e(e=0)),o);var je=(e,o)=>{for(var t in o)rt(e,t,{get:o[t],enumerable:!0})};var a,q=z(()=>{"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 G,Ce=z(()=>{"use strict";G=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function pt(e){let o={};for(let t of e)go[t]&&(o[t]={...go[t]});return o}function gt(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:{...M},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:pt(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 _e(e){let o=(e.surveyTypes??[]).filter(c=>G.includes(c)),t=[...new Set([...o,...G])],n=gt(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:ee(r.header,i.header),footer:ee(r.footer,i.footer),theme:ee(r.theme,i.theme),layout:ee(r.layout,i.layout),buttons:ee(r.buttons,i.buttons),logo:ee(r.logo,i.logo),colorScheme:ee(r.colorScheme,i.colorScheme),typography:ee(r.typography,i.typography),motion:ee(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 M,go,Xe=z(()=>{"use strict";Ce();M={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},go={MCQ:{cardStyle:"outlined",selectedAccent:M.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:M.secondary,hoverBorderColor:M.accent},TEXTFIELD:{inputRadius:8,focusRing:M.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:M.secondary,labelColor:M.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:M.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:M.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:M.primary,cellPadding:8,accentColor:M.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:M.accent,cellSize:40,tooltipBg:"#1F2937",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:M.primary,rowLabelWidth:180,unselectedStarOpacity:.5,graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.primary},SLIDER_MATRIX:{trackColor:M.accent,thumbColor:M.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:M.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:M.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:M.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:M.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});import*as ve from"fs";import*as xe from"path";function bo(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 E(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function wo(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function Te(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function So(e){let o={global:{},questionTypes:{}},t=o.global,n={},i={},r={},s={},c={},d={},h={},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"]&&mo[e["--cfm-max-width"]]&&(c.width=mo[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&yo[e["--cfm-border-radius"]]&&(c.borderStyle=yo[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],ho[e["--cfm-font-family"]]&&(c.fontStyle=ho[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=Te(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let $=E(e["--cfm-motion-duration"]);$!==void 0&&(h.durationMs=$,h.enabled=$>0)}e["--cfm-header-height"]&&(i.height=E(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(i.logoBoxWidth=E(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(i.logoBoxHeight=E(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(i.logoPadding=E(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=E(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(i.companyNameFontWeight=Te(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(i.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(i.contentPaddingX=E(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=E(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(r.logoHeight=E(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(r.paddingY=E(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(r.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&&(m.MCQ=S);let T={};e["--cfm-input-radius"]&&(T.inputRadius=E(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(T.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(T.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(T.inputPadding=E(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(T.inputHeight=E(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(T.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(T).length&&(m.TEXTFIELD=T);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&&(m.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=wo(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&&(m.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=Te(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"])&&(m.CSAT_MATRIX=p);let g={};e["--cfm-star-color"]&&(g.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(g.badgeColor=e["--cfm-badge-color"]),k!==void 0&&(g.rowLabelWidth=k),e["--cfm-star-unselected-opacity"]&&(g.unselectedStarOpacity=Te(e["--cfm-star-unselected-opacity"])),Object.keys(g).length&&(m.RATING_MATRIX=g);let C={};e["--cfm-slider-track"]&&(C.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(C.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(C.tickColor=e["--cfm-slider-tick"]),k!==void 0&&(C.rowLabelWidth=k),e["--cfm-slider-row-band"]&&(C.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(C.tickBadgeSize=E(e["--cfm-slider-tick-size"])),Object.keys(C).length&&(m.SLIDER_MATRIX=C);let L={};e["--cfm-upload-accent"]&&(L.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&(L.dropzonePadding=E(e["--cfm-upload-padding"])),Object.keys(L).length&&(m.FILE_UPLOAD=L);let y={};e["--cfm-media-max-width"]&&(y.mediaMaxWidth=wo(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(y.mediaRadius=E(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(y.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(y.captionSize=E(e["--cfm-media-caption-size"])),Object.keys(y).length&&(m.TEXT_AND_MEDIA=y);let A={};e["--cfm-heatmap-pin"]&&(A.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(A.pinSize=E(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(A.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(A.overlayOpacity=Te(e["--cfm-heatmap-overlay-opacity"])),Object.keys(A).length&&(m.HEATMAP=A);let x={};return e["--cfm-rank-item-bg"]&&(x.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(x.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(x.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(x.itemPadding=E(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(x.itemGap=E(e["--cfm-rank-item-gap"])),Object.keys(x).length&&(m.RANK_ORDER=x),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(h).length&&(t.motion=h),o}function ue(e){let o=[xe.join(e,"src","styles","survey-theme.css"),xe.join(e,"src","app","survey-theme.css"),xe.join(e,"src","styles","globals.css"),xe.join(e,"src","app","globals.css")];for(let t of o)if(ve.existsSync(t)&&ve.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var mo,yo,ho,De=z(()=>{"use strict";mo={"36rem":"narrow","48rem":"standard","64rem":"wide"},yo={"0px":"sharp","12px":"rounded","9999px":"pill"},ho={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});import*as Le from"fs";import*as Co from"path";function yt(e){for(let o of mt){let t=Co.join(e,o);if(Le.existsSync(t))return t}return null}function ht(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 To(e){let o=yt(e);if(!o)return null;let t=Le.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=ht(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 mt,xo=z(()=>{"use strict";mt=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var ko={};je(ko,{logSeedSource:()=>Ve,resolveInitialConfig:()=>ge,writeResolvedUiConfig:()=>Je});import*as Q from"fs";import*as oe from"path";function He(e){return e.filter(o=>G.includes(o))}function $o(e){try{let o=JSON.parse(Q.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function St(e){let o={global:{}};if(!Q.existsSync(e))return o;let t=Q.readFileSync(e,"utf8"),n=new Set;for(let r of G)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 Eo(e,o){let t=oe.join(e,o);if(!Q.existsSync(t))return null;let n=Q.readFileSync(t);if(n.length>wt)return{fileName:o,dataUrl:""};let i=oe.extname(o).toLowerCase(),r=bt[i]??"application/octet-stream";return{fileName:o,dataUrl:`data:${r};base64,${n.toString("base64")}`}}function Ro(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=Eo(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 Ao(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 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"),i=oe.join(o,"public"),r=He(e.surveyTypes),s={},c="defaults",d=ue(o);if(d){let x=Q.readFileSync(d,"utf8"),$=bo(x);Object.keys($).length>0&&(s=So($),c="survey-theme.css")}let h=St(n);s=Ao(s,h);let m=$o(t);m&&(s=Ao(s,m),c="survey-ui-config.json");let S=oe.join(o,"survey-ui-config.final.json"),T=$o(S),F=!!m?.configuredAt,k=!!T?.configuredAt;if(T&&k&&!F){let x=Ro(i,T.global?.logo);x&&(s.global={...s.global??{},logo:{fileName:x.fileName,url:x.url}})}let R=Ro(i,s.global?.logo),p=To(o),g=!!m?.configuredAt,C=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),L=p?.mode==="image"?p.fileName:null,y=!g&&C&&L!=null&&R?.fileName!==L;if(R&&!y)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(p?.mode==="image"){let x=Eo(i,p.fileName);s.global={...s.global??{},logo:{fileName:p.fileName,url:x?.dataUrl||null}}}else p?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??p.label});return s.surveyTypes=He(s.surveyTypes??r),s.surveyTypes?.length||(s.surveyTypes=r),e.instanceId&&(s.instanceId=e.instanceId),{config:_e(s),source:c}}function Ve(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 Je(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??He(G),{config:n}=ge({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),i=oe.join(o,"survey-ui-config.json");return Q.writeFileSync(i,JSON.stringify(n,null,2),"utf8"),i}var pe,wt,bt,$e=z(()=>{"use strict";q();Xe();De();Ce();xo();pe=a,wt=512e3,bt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function b(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function l(e,o){return typeof e=="string"&&e.length?e:o}function _t(){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 vt(){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 Be(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 Do(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 Ze(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 Dt(e,o){let t=l(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${b(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${b(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${b(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 Lt(e,o){e["--cfm-input-radius"]=`${b(o.inputRadius,8)}px`,e["--cfm-input-border"]=l(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${b(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${b(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=l(o.placeholderColor,"#9CA3AF")}function Mt(e,o){e["--cfm-nps-cell-size"]=`${b(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${b(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,"")),Do(e,o),Be(e,o)}function Bt(e,o){e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${b(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${b(o.cellPadding,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=l(o.carouselDotColor,"#2563EB")),Ze(e,o,"matrix")}function Ot(e,o){e["--cfm-csat-emoji-size"]=`${b(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(b(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(b(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${b(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"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-accent"]??"#00B5AD"),Ze(e,o,"csat"),Be(e,o)}function Ut(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"]=`${b(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(b(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(b(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-primary"]??"#1A1F36"),Ze(e,o,"rating"),Be(e,o)}function zt(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"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-slider-row-band"]=l(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${b(o.tickBadgeSize,28)}px`,Do(e,o),Be(e,o)}function qt(e,o){e["--cfm-upload-border-color"]=l(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${b(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=l(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=l(o.dropzoneStyle,"dashed")}function Wt(e,o){e["--cfm-media-max-width"]=`${b(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${b(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=l(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${b(o.captionSize,14)}px`}function Xt(e,o){e["--cfm-heatmap-pin"]=l(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${b(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=l(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(b(o.overlayOpacity,0))}function Ht(e,o){let t=W(o.drag)??o,n=W(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"]=`${b(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${b(t.itemGap,8)}px`,e["--cfm-rank-handle"]=l(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=l(n.selectBorderColor,"#E5E7EB")}function Oe(e){let o=W(e.global)??{},t=W(o.colorScheme)??{},n=W(o.header)??{},i=W(o.footer)??{},r=W(o.theme)??{},s=W(o.layout)??{},c=W(o.typography)??{},d=W(o.motion)??{},h=e.questionTypes??{},m=l(s.fontStyle,"modern"),S=vo[m]??l(c.fontFamily,vo.modern),T=l(s.width,"standard"),F=l(s.borderStyle,"rounded"),k=l(r.cellSelectedColor,l(t.accent,"#00B5AD")),R=l(r.focusRingColor,l(t.accent,"#00B5AD")),p=l(r.selectedBackground,l(t.secondary,"#E8F5FD")),g={"--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":No[T]??No.standard,"--cfm-border-radius":_o[F]??_o.rounded,"--cfm-font-family":S,"--cfm-heading-weight":String(b(c.headingWeight,700)),"--cfm-motion-duration":`${b(d.durationMs,200)}ms`,"--cfm-header-height":`${b(n.height,120)}px`,"--cfm-header-logo-width":`${b(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${b(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${b(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":`${b(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(b(n.companyNameFontWeight,600)),"--cfm-header-border":l(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${b(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",..._t(),"--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":`${b(i.logoWidth,120)}px`,"--cfm-footer-logo-height":`${b(i.logoHeight,32)}px`,"--cfm-footer-padding-y":`${b(i.paddingY,24)}px`,"--cfm-footer-padding-x":`${b(i.paddingX,40)}px`,...vt(),"--cfm-card-bg":l(r.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(r.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${b(r.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":r.cardShadowEnabled===!1?"none":`0 ${b(r.cardShadowOffsetY,1)}px ${b(r.cardShadowBlur,3)}px ${l(r.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":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":`${b(r.progressTrackHeight,12)}px`,"--cfm-progress-track":l(r.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(r.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${b(r.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${b(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")},C=[["MCQ",Dt],["TEXTFIELD",Lt],["NPS_SCALE",Mt],["CFM_MATRIX",Bt],["CSAT_MATRIX",Ot],["RATING_MATRIX",Ut],["SLIDER_MATRIX",zt],["FILE_UPLOAD",qt],["TEXT_AND_MEDIA",Wt],["HEATMAP",Xt],["RANK_ORDER",Ht]];for(let[L,y]of C){let A=W(h[L]);A&&y(g,A)}return g}function eo(e){let o=e.questionTypes??{},t=W(o.MCQ),n=W(o.NPS_SCALE),i=W(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 No,_o,vo,oo=z(()=>{"use strict";No={narrow:"36rem",standard:"48rem",wide:"64rem"},_o={sharp:"0px",rounded:"12px",pill:"9999px"},vo={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'}});import*as te from"fs";import*as se from"path";function Vt(e){return`:root {
|
|
3
3
|
${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>` ${t}: ${n};`).join(`
|
|
4
4
|
`)}
|
|
5
|
-
}`}function Jt(e,o){let t=
|
|
5
|
+
}`}function Jt(e,o){let t=Oe(e),n=Vt(t),i=o.match(/:root\s*\{[\s\S]*?\n\}/);return i?o.replace(i[0],n):`${n}
|
|
6
6
|
|
|
7
|
-
${o}`}function Gt(e){let o=se.join(e,"src","styles","survey-theme.css");if(
|
|
8
|
-
`)}function
|
|
9
|
-
${s}`,
|
|
7
|
+
${o}`}function Gt(e){let o=se.join(e,"src","styles","survey-theme.css");if(te.existsSync(se.dirname(o)))return o;let t=se.join(e,"src","app","survey-theme.css");return te.existsSync(se.dirname(t))?t:(te.mkdirSync(se.dirname(o),{recursive:!0}),o)}function Lo(e,o,t){let n=te.readFileSync(t,"utf8"),i=Gt(e),r=Jt(o,n);return te.writeFileSync(i,r,"utf8"),i}var Mo=z(()=>{"use strict";oo()});import*as he from"fs";import*as we from"path";function Bo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(e,o){return JSON.stringify(e)===JSON.stringify(o)}function ye(e){return typeof e=="string"&&e.startsWith("data:")&&e.length>80?`${e.slice(0,48)}\u2026 (${e.length} chars)`:e}function Uo(e,o,t,n){if(Oo(e,o)){n.unchangedCount+=1;return}if(e===void 0&&o!==void 0){n.added.push({path:t,before:void 0,after:ye(o)});return}if(e!==void 0&&o===void 0){n.removed.push({path:t,before:ye(e),after:void 0});return}if(Array.isArray(e)&&Array.isArray(o)){Oo(e,o)?n.unchangedCount+=1:n.changed.push({path:t,before:ye(e),after:ye(o)});return}if(Bo(e)&&Bo(o)){let i=new Set([...Object.keys(e),...Object.keys(o)]);for(let r of i){if(Qt.has(r)&&t==="")continue;let s=t?`${t}.${r}`:r;Uo(e[r],o[r],s,n)}return}n.changed.push({path:t,before:ye(e),after:ye(o)})}function to(e,o){let t={changed:[],added:[],removed:[],unchangedCount:0};return Uo(e,o,"",t),t}function Ue(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 ne(e){return{seedPath:we.join(e,"survey-ui-config.seed.json"),finalPath:we.join(e,"survey-ui-config.final.json"),diffJsonPath:we.join(e,"survey-ui-config.diff.json"),diffMdPath:we.join(e,"survey-ui-config.diff.md"),activeConfigPath:we.join(e,"survey-ui-config.json")}}function ze(e,o,t){let n=ne(e),i=to(o,t);return he.writeFileSync(n.seedPath,JSON.stringify(o,null,2),"utf8"),he.writeFileSync(n.finalPath,JSON.stringify(t,null,2),"utf8"),he.writeFileSync(n.diffJsonPath,JSON.stringify(i,null,2),"utf8"),he.writeFileSync(n.diffMdPath,Ue(i),"utf8"),he.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),i}var Qt,Re=z(()=>{"use strict";Qt=new Set(["configuredAt","instanceId"])});function qo(e){return zo[e]?zo[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 zo,Wo=z(()=>{"use strict";zo={"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 Ae={};je(Ae,{runApplyUiConfig:()=>rn});import*as v from"fs";import*as B from"path";function Yt(e,o){if(o&&v.existsSync(o))return o;let t=B.join(e,"survey-ui-config.json");if(v.existsSync(t))return t;let n=ne(e).finalPath;if(v.existsSync(n))return n;throw new Error("No survey-ui-config.json found. Complete the wizard or run confirm-ui-config first.")}function Zt(e,o){let t=B.relative(B.dirname(o),o),n=(o.includes(`${B.sep}styles${B.sep}`),"./survey-theme.css"),i=[B.join(e,"src","app","globals.css"),B.join(e,"src","styles","globals.css")];for(let r of i){if(!v.existsSync(r))continue;let s=v.readFileSync(r,"utf8"),c=`@import '${n}';`;if(s.includes("survey-theme.css"))return;s.includes(c)||(s=`${c}
|
|
9
|
+
${s}`,v.writeFileSync(r,s,"utf8"));return}}function en(e,o){let t=eo(o),n=B.join(e,"src","lib");v.mkdirSync(n,{recursive:!0});let i=B.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 v.writeFileSync(i,s,"utf8"),i}function on(e){let o=B.join(e,"src","components");v.mkdirSync(o,{recursive:!0});let t=B.join(o,"SurveyUiConfigInit.tsx");return v.existsSync(t)||v.writeFileSync(t,Kt,"utf8"),t}function tn(e,o){let t=B.join(e,"src","lib","uiConfig.ts");if(v.existsSync(t))return;let n=B.join(o,"docs","templates","uiConfig.ts");v.existsSync(n)&&(v.mkdirSync(B.dirname(t),{recursive:!0}),v.copyFileSync(n,t))}function nn(e,o){let t=e.replace(/\.json$/,".diff.json");if(v.existsSync(t))try{let n=JSON.parse(v.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)qo(r)==="unknown"&&o.push(`Unmapped config path (verify manually): ${r}`)}catch{}}function rn(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=Yt(o,e.configPath),n=B.join(__dirname,"..",".."),i=B.join(n,"templates","survey-theme.css"),r=B.join(n,"templates"),s=[],c=JSON.parse(v.readFileSync(t,"utf8")),d=[...new Set([...c.surveyTypes??[],...G])],h=_e({...c,surveyTypes:d}),m=Lo(o,h,i);Zt(o,m),tn(o,r),en(o,h);let S;e.skipInitComponent||(S=on(o));let T=Oe(h),F=eo(h);nn(t,s),console.log(`${K.green}\u2705 Applied UI config \u2192 ${m}${K.reset}`),console.log(`${K.dim} ${Object.keys(T).length} CSS variables regenerated${K.reset}`),console.log(`${K.dim} DOM attrs: ${Object.entries(F).map(([k,R])=>`${k}=${R}`).join(", ")}${K.reset}`),S&&console.log(`${K.dim} Runtime init: ${S} (mount in layout if not already)${K.reset}`);for(let k of s)console.log(`${K.yellow} \u26A0 ${k}${K.reset}`);return{configPath:t,themeCssPath:m,cssVarCount:Object.keys(T).length,domAttributes:F,initComponentPath:S,warnings:s}}var K,Kt,Ee=z(()=>{"use strict";q();Xe();oo();Mo();Re();Wo();Ce();K=a,Kt=`'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
|
-
`});import*as ce from"fs";import*as
|
|
36
|
-
${
|
|
37
|
-
`),console.log(
|
|
38
|
-
${X.green}\u2705 Fetched final config (review mode)${X.reset}`),console.log(`${X.green} Final: ${s.finalPath}${X.reset}`),console.log(`${X.green} Diff: ${s.diffMdPath}${X.reset}`),console.log(`${X.yellow} ${S.changed.length} changed, ${S.added.length} added, ${S.removed.length} removed${X.reset}`),console.log(`${X.dim} Apply when ready: npx cfm-sdk confirm-ui-config${X.reset}`)}var X,
|
|
39
|
-
`);let o=await
|
|
40
|
-
\u274C ${
|
|
41
|
-
`),process.exit(1));let n=process.platform==="win32",
|
|
42
|
-
\u{1F4E6} ${
|
|
43
|
-
\u2714 ${
|
|
35
|
+
`});import*as ce from"fs";import*as Go from"http";import*as Qo from"https";import*as ro from"path";function qe(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 Jo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?Qo:Go).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 ln(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Qo:Go).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 ae(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:i,apiBase:r,surveyId:s}=e,c=ro.join(o,"public");ce.existsSync(c)||ce.mkdirSync(c,{recursive:!0});let d=ro.join(c,t);if(n){let h=await Jo(n);return ce.writeFileSync(d,h),d}if(i&&r&&s){let h=await ln(`${r.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${i}`}}),m=await Jo(h.downloadUrl);return ce.writeFileSync(d,m),d}throw new Error("Logo download requires logoUrl from wizard poll or CFM_INSTANCE_ID + CFM_DEPLOY_API_BASE")}var We=z(()=>{"use strict"});var ot={};je(ot,{runConfirmUiConfig:()=>mn});import*as Y from"fs";function gn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function mn(e={}){let o=process.env.INIT_CWD??process.cwd(),t=ne(o);if(!Y.existsSync(t.finalPath))throw new Error(`Missing ${t.finalPath}. Run customize-ui with --review and complete the wizard first.`);let n=JSON.parse(Y.readFileSync(Y.existsSync(t.seedPath)?t.seedPath:t.activeConfigPath,"utf8")),i=JSON.parse(Y.readFileSync(t.finalPath,"utf8")),r=to(n,i);if(console.log(`
|
|
36
|
+
${H.bold}${H.cyan}\u{1F4CB} UI config review${H.reset}
|
|
37
|
+
`),console.log(Ue(r)),e.diffOnly){Y.writeFileSync(t.diffJsonPath,JSON.stringify(r,null,2),"utf8"),Y.writeFileSync(t.diffMdPath,Ue(r),"utf8"),console.log(`${H.dim} Updated ${t.diffMdPath}${H.reset}`);return}Y.writeFileSync(t.activeConfigPath,JSON.stringify(i,null,2),"utf8"),console.log(`${H.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${H.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(Ee(),Ae));s({projectRoot:o,configPath:t.activeConfigPath});let c=i.global?.logo;if(!c?.fileName)return;let d=process.env.CFM_INSTANCE_ID,h=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),m=d?gn(d):null;try{await ae({projectRoot:o,fileName:c.fileName,logoUrl:c.url,jwt:d??void 0,apiBase:h||void 0,surveyId:m??void 0}),console.log(`${H.green} Logo saved to public/${c.fileName}${H.reset}`),c.url&&console.log(`${H.dim} Public logo URL: ${c.url}${H.reset}`)}catch(S){console.log(`${H.yellow} Logo not downloaded \u2014 ${S instanceof Error?S.message:String(S)}${H.reset}`)}}var H,tt=z(()=>{"use strict";q();Re();We();H=a});var nt={};je(nt,{runFetchUiConfig:()=>Sn});import*as Pe from"fs";import*as yn from"http";import*as hn from"https";async function wn(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?hn:yn).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 bn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function Sn(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=bn(o);if(!i)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let r=process.env.INIT_CWD??process.cwd(),s=ne(r),c=Pe.existsSync(s.seedPath)?s.seedPath:s.activeConfigPath;if(!Pe.existsSync(c))throw new Error(`Missing seed config at ${c}. Run customize-ui --review first.`);let d=await wn(`${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 h=qe(d)??d.config,m=JSON.parse(Pe.readFileSync(c,"utf8")),S=ze(r,m,h),T=h.global?.logo;if(T?.fileName)try{await ae({projectRoot:r,fileName:T.fileName,logoUrl:d.logoUrl,jwt:o,apiBase:t,surveyId:i}),console.log(`${X.green} Logo saved to public/${T.fileName}${X.reset}`)}catch(F){console.warn(`${X.yellow} Logo download failed: ${F}${X.reset}`)}console.log(`
|
|
38
|
+
${X.green}\u2705 Fetched final config (review mode)${X.reset}`),console.log(`${X.green} Final: ${s.finalPath}${X.reset}`),console.log(`${X.green} Diff: ${s.diffMdPath}${X.reset}`),console.log(`${X.yellow} ${S.changed.length} changed, ${S.added.length} added, ${S.removed.length} removed${X.reset}`),console.log(`${X.dim} Apply when ready: npx cfm-sdk confirm-ui-config${X.reset}`)}var X,it=z(()=>{"use strict";q();Re();We();X=a});q();q();import{execSync as co,spawn as st}from"child_process";function de(e){try{let o=process.platform==="win32"?`where ${e}`:`command -v ${e}`;return co(o,{stdio:"ignore"}),!0}catch{return!1}}var ct={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function Se(e,o){try{let t=`${e} ${o.join(" ")}`;return co(t,ct),!0}catch{return!1}}function Ne(e,o){return new Promise(t=>{st(e,o,{stdio:"inherit",shell:!0}).on("close",i=>{t(i)})})}import at from"readline/promises";import{stdin as lt,stdout as dt}from"process";async function fe(e){let o=at.createInterface({input:lt,output:dt});try{return(await o.question(e)).trim()}finally{o.close()}}async function ao(){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 fe("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?de("winget")?(console.log(`
|
|
42
|
+
\u{1F4E6} ${a.green}winget package manager found! Installing Node.js v18+ in background...${a.reset}`),Se("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?de("brew")?(console.log(`
|
|
49
|
+
\u{1F4E6} ${a.green}Homebrew package manager found! Installing Node.js v18+ in background...${a.reset}`),Se("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 Ne(n,
|
|
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}`)}q();async function lo(){console.log(`
|
|
58
|
+
${a.dim}Step 2/4: Checking Vercel CLI...${a.reset}`);let e="vercel",o=!1;if(de("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 fe("\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}`),Se("npm",["install","-g","vercel"])&&de("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}}q();import{execSync as ft}from"child_process";var ut={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function fo(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{ft(e?"npx --yes vercel whoami":"vercel whoami",ut),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 fe("\u{1F449} Press [Enter] to login to Vercel... ");let n=["login"],i=e?"npx":"vercel",r=e?["--yes","vercel",...n]:n;if(await Ne(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}q();async function uo(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 Ne(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 po(){console.log(`
|
|
67
|
+
${a.bold}${a.cyan}\u{1F680} Starting CFM Vercel Deployment...${a.reset}
|
|
68
|
+
`),await ao();let{vercelCmd:e,useNpx:o}=await lo(),t=await fo(o);await uo(o,t)}q();import*as Fe from"http";import*as P from"fs";import*as _ from"path";function U(e){return e instanceof Error?e.message:String(e)}$e();q();import*as N from"fs";import*as j from"path";De();De();import*as u from"fs";import*as f from"path";import{execSync as Ct}from"child_process";function re(e,o){if(u.existsSync(e)){u.mkdirSync(o,{recursive:!0});for(let t of u.readdirSync(e,{withFileTypes:!0})){let n=f.join(e,t.name),i=f.join(o,t.name);t.isDirectory()?re(n,i):u.copyFileSync(n,i)}}}function Ge(e){let o=[],t=e;for(let n=0;n<6;n++){let i=f.join(t,"node_modules");u.existsSync(i)&&o.push(i);let r=f.dirname(t);if(r===t)break;t=r}return o}function Tt(e,o){let t=Ge(e);for(let n of t)for(let i of["@explorer02/cfm-survey-sdk","@repo/sdk"])for(let r of["mjs","js"]){let s=f.join(n,i,"dist",`index.${r}`);if(u.existsSync(s))return s}for(let n of["mjs","js"]){let i=f.join(o,"dist",`index.${n}`);if(u.existsSync(i))return i}throw new Error("Could not resolve @explorer02/cfm-survey-sdk for preview build")}function xt(e,o){let t=[...Ge(o).map(n=>f.join(n,"vite","bin","vite.js")),f.join(e,"node_modules","vite","bin","vite.js")];for(let n of t)if(u.existsSync(n))return n;throw new Error("Vite is required for agent preview builds. Install vite in the project or SDK package.")}function $t(e){let o=f.join(e,"src","components");if(!u.existsSync(f.join(o,"Question.tsx")))throw new Error(`Missing src/components/Question.tsx in ${e}. Build the survey UI before export-previews.`);let t=f.join(e,"src","lib"),n=f.join(e,"public");return{componentsDir:o,libDir:u.existsSync(t)?t:void 0,publicDir:u.existsSync(n)?n:void 0}}function Rt(e,o,t){let n=f.join(e,"templates","docs","templates"),i=f.join(o,"agent","src","lib");u.mkdirSync(i,{recursive:!0});let r=f.join(n,"uiConfig.ts");if(!u.existsSync(r))throw new Error(`Missing template uiConfig.ts at ${r}`);u.copyFileSync(r,f.join(i,"uiConfig.ts"));let s=f.join(o,"agent","survey-ui-config.json"),c=f.join(t,"survey-ui-config.json");u.existsSync(c)?u.copyFileSync(c,s):u.existsSync(s)||u.writeFileSync(s,JSON.stringify({version:"1.0",global:{},questionTypes:{},placeholders:{}},null,2))}function At(e,o,t){let n=f.join(e,"templates","docs","templates"),i=f.join(o,"agent","src","components"),r=f.join(o,"agent","src","lib","surveyUi");u.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 h of s){let m=f.join(n,h);u.existsSync(m)&&u.copyFileSync(m,f.join(i,h))}let c=["selectionStyles.ts","labelStyles.ts","heatmapCoords.ts"];for(let h of c){let m=f.join(n,h);u.existsSync(m)&&u.copyFileSync(m,f.join(r,h))}let d=f.join(n,"heatmapCoords.ts");u.existsSync(d)&&u.copyFileSync(d,f.join(i,"heatmapCoords.ts")),Rt(e,o,t)}function Et(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 kt(e,o,t,n){let
|
|
89
|
+
mountPreview(<QuestionPreview question={question} />);`}}function kt(e,o,t,n){let i=Tt(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,43 @@ 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
124
|
`;u.writeFileSync(f.join(e,"vite.config.mjs"),s)}function Ft(e,o){let t=u.readFileSync(e,"utf8");if(t.includes("preview-bridge.inline"))return;let n=`<script>${o}</script>`;t=t.includes("</body>")?t.replace("</body>",`${n}
|
|
125
125
|
</body>`):`${t}
|
|
126
|
-
${n}`,u.writeFileSync(e,t)}function Pt(e){return e.replace(/_/g," ")}async function
|
|
126
|
+
${n}`,u.writeFileSync(e,t)}function Pt(e){return e.replace(/_/g," ")}async function Fo(e){let{projectRoot:o,outputDir:t,keys:n}=e,i=f.join(__dirname,"..",".."),r=f.join(i,"templates","preview-harness","vite-app");if(!u.existsSync(r))throw new Error(`Missing Vite preview harness template at ${r}`);let s=$t(o),c=f.join(t,".preview-vite-work");u.existsSync(c)&&u.rmSync(c,{recursive:!0,force:!0}),re(r,c),u.mkdirSync(f.join(c,"agent","src"),{recursive:!0}),re(s.componentsDir,f.join(c,"agent","src","components")),s.libDir&&re(s.libDir,f.join(c,"agent","src","lib")),s.publicDir&&re(s.publicDir,f.join(c,"agent","public")),At(i,c,o);let d=f.join(o,"survey-ui-config.json");u.existsSync(d)&&u.copyFileSync(d,f.join(c,"agent","survey-ui-config.json"));let h=ue(o),m=f.join(c,"src","survey-theme.css");u.writeFileSync(m,h?u.readFileSync(h,"utf8"):u.readFileSync(f.join(i,"templates","survey-theme.css"),"utf8")),u.mkdirSync(f.join(c,"src","entries"),{recursive:!0});for(let C of n)u.mkdirSync(f.join(c,C),{recursive:!0}),u.writeFileSync(f.join(c,C,"index.html"),`<!DOCTYPE html>
|
|
127
127
|
<html lang="en">
|
|
128
128
|
<head>
|
|
129
129
|
<meta charset="UTF-8" />
|
|
130
130
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
131
|
-
<title>${Pt(
|
|
131
|
+
<title>${Pt(C)} \u2014 CFM Preview</title>
|
|
132
132
|
</head>
|
|
133
133
|
<body>
|
|
134
134
|
<div id="root"></div>
|
|
135
|
-
<script type="module" src="../src/entries/${
|
|
135
|
+
<script type="module" src="../src/entries/${C}.tsx"></script>
|
|
136
136
|
</body>
|
|
137
|
-
</html>`),u.writeFileSync(f.join(c,"src","entries",`${
|
|
138
|
-
${I.green}\u2705 UI configuration saved to ${t}${I.reset}`);try{let{runApplyUiConfig
|
|
139
|
-
${I.bold}${I.cyan}\u{1F3A8} Survey UI Customization Wizard${I.reset}`),console.log(`${I.bold}\u{1F517} Client wizard link \u2014 share this URL only:${I.reset}`),console.log(` ${I.green}${p}${I.reset}`),console.log(`${I.dim} Port ${
|
|
140
|
-
`),sn(p)}),
|
|
141
|
-
${
|
|
142
|
-
`),
|
|
143
|
-
`));let S=[...
|
|
144
|
-
${
|
|
145
|
-
`),dn(
|
|
146
|
-
${
|
|
147
|
-
${
|
|
148
|
-
`);try{await
|
|
149
|
-
${
|
|
150
|
-
${
|
|
151
|
-
${
|
|
152
|
-
${
|
|
153
|
-
${
|
|
154
|
-
${
|
|
155
|
-
${
|
|
156
|
-
${
|
|
157
|
-
${
|
|
137
|
+
</html>`),u.writeFileSync(f.join(c,"src","entries",`${C}.tsx`),Et(C));u.writeFileSync(f.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)),kt(c,o,i,n);let S=xt(i,o),T=Ge(o).join(f.delimiter);Ct(`node "${S}" build --config "${f.join(c,"vite.config.mjs")}"`,{cwd:c,stdio:"inherit",env:{...process.env,NODE_PATH:T}});let F=f.join(t,"previews");u.mkdirSync(F,{recursive:!0});let k=f.join(c,"dist"),R=u.readFileSync(f.join(i,"templates","preview-harness","preview-bridge.inline.js"),"utf8");for(let C of n){let L=f.join(k,C),y=f.join(F,C);if(!u.existsSync(f.join(L,"index.html")))throw new Error(`Vite build did not produce ${C}/index.html`);u.existsSync(y)&&u.rmSync(y,{recursive:!0,force:!0}),re(L,y),Ft(f.join(y,"index.html"),R)}let p=f.join(k,"assets");u.existsSync(p)&&re(p,f.join(F,"assets"));let g=f.join(c,"agent","public");if(u.existsSync(g))for(let C of u.readdirSync(g)){let L=f.join(g,C);u.statSync(L).isFile()&&u.copyFileSync(L,f.join(F,C))}u.rmSync(c,{recursive:!0,force:!0})}import*as Qe from"fs";import*as Ke from"path";function Me(e){if(e)return e;let o=process.cwd();if(Qe.existsSync(Ke.join(o,"src","components","Question.tsx")))return o;let t=process.env.INIT_CWD;return t&&Qe.existsSync(Ke.join(t,"src","components","Question.tsx"))?t:o}var Po=["header","footer","survey_page"],Io={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"]},ui=[...Po,...Object.values(Io).flat()];function jo(e){let o=new Set(Po);for(let t of e)for(let n of Io[t]??[])o.add(n);return[...o]}var O=a;function It(){return j.join(__dirname,"..","..","templates")}function jt(e){let o=N.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 Nt(e,o){let t=new Set(jo(o));return e.filter(n=>t.has(n))}function Ye(e,o,t){if(N.existsSync(e))for(let n of N.readdirSync(e)){let i=j.join(e,n),r=j.posix.join(o,n);if(N.statSync(i).isDirectory())Ye(i,r,t);else{let s=j.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:N.statSync(i).size})}}}async function me(e={}){let o=Me(e.projectRoot),t=e.outputDir??j.join(o,"out"),n=It(),i=j.join(n,"preview-harness");e.useTemplatesOnly&&console.log(`${O.dim} Using SDK template preview harness only (--use-templates-only)${O.reset}`);let r=j.join(i,"previewPages.js"),{PREVIEW_PAGE_DEFS:s,buildPreviewHtml:c,PREVIEW_KEYS:d}=Ie(r),h=(()=>{let p=ue(o);return p?(console.log(`${O.dim} Using project theme: ${j.relative(o,p)}${O.reset}`),N.readFileSync(p,"utf8")):N.readFileSync(j.join(n,"survey-theme.css"),"utf8")})(),m=N.readFileSync(j.join(i,"preview-bridge.inline.js"),"utf8"),S=e.surveyTypes;if(!S){let p=j.join(o,"implementation_plan.md");S=N.existsSync(p)?jt(p):["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]}let T=Nt(d,S),F=j.join(t,"previews");if(N.existsSync(F)&&(N.rmSync(F,{recursive:!0,force:!0}),console.log(`${O.dim} Cleared previous preview output${O.reset}`)),N.mkdirSync(F,{recursive:!0}),!e.useTemplatesOnly)try{console.log(`${O.dim} Building previews from agent components (Vite)\u2026${O.reset}`),await Fo({projectRoot:o,outputDir:t,keys:T});let p={};for(let C of T)p[C]=`previews/${C}/index.html`;N.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(p,null,2));let g=[];return Ye(j.join(t,"previews"),"previews",g),console.log(`${O.green}\u2705 Exported ${T.length} agent component previews \u2192 ${t}${O.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:g,surveyTypes:S}}catch(p){console.warn(`${O.yellow}\u26A0 Agent Vite preview build failed; falling back to template harness.${O.reset}`),console.warn(`${O.dim} ${U(p)}${O.reset}`)}for(let p of s){if(!T.includes(p.key))continue;let g=j.join(t,"previews",p.key);N.mkdirSync(g,{recursive:!0}),N.writeFileSync(j.join(g,"index.html"),c(p,h,m))}let k={};for(let p of T)k[p]=`previews/${p}/index.html`;N.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(k,null,2));let R=[];return Ye(j.join(t,"previews"),"previews",R),console.log(`${O.green}\u2705 Exported ${T.length} preview pages \u2192 ${t}${O.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:R,surveyTypes:S}}var I=a,ke=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];function Ho(e){return new Promise(o=>{let t=Fe.createServer();t.listen(e,()=>{t.close(()=>o(e))}),t.on("error",()=>o(Ho(e+1)))})}function Xo(e){return new Promise((o,t)=>{let n="";e.on("data",i=>n+=i),e.on("end",()=>o(n)),e.on("error",t)})}function sn(e){let{exec:o}=Ie("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function no(e){let o=_.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 cn(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 ke)e.includes(r)&&o.add(r);let i=e.matchAll(/\|\s*`([A-Z_]+)`\s*\|/g);for(let r of i)ke.includes(r[1])&&o.add(r[1]);return{surveyTypes:o.size>0?[...o]:[...ke],instanceId:t}}async function an(e){return new Promise(o=>{try{let t=Fe.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 io(e){let o=_.join(e,"out","previews");P.existsSync(o)&&(P.rmSync(o,{recursive:!0,force:!0}),console.log(`${I.dim} Removed local preview files: out/previews/${I.reset}`))}async function Vo(){let e=process.env.INIT_CWD||process.cwd(),o=_.join(e,"public"),t=_.join(e,"survey-ui-config.json"),n=_.join(e,"implementation_plan.md"),i=_.join(__dirname,"..","..","templates"),r=_.join(i,"wizard-dist"),s=process.env.CFM_PREVIEW_URL??"http://localhost:3000",c={},d=_.join(e,"out","previews"),h=_.join(d,"manifest.json");console.log(`${I.dim} Exporting component previews for local wizard\u2026${I.reset}`),await me({projectRoot:e,surveyTypes:[...ke]}),P.existsSync(h)&&(c=JSON.parse(P.readFileSync(h,"utf8")));let m=await Ho(4200),S=`http://localhost:${m}`;return new Promise((T,F)=>{let k=Fe.createServer(async(p,g)=>{try{let C=p.url??"/",L=C.split("?")[0];if(p.method==="GET"&&L.startsWith("/api/project-logo/")){let y=_.basename(decodeURIComponent(L.slice(18))),A=_.join(o,y),x=_.normalize(A);if(x.startsWith(o)&&P.existsSync(x)&&P.statSync(x).isFile()){let $=P.readFileSync(x);g.writeHead(200,{"Content-Type":no(x)}),g.end($);return}g.writeHead(404),g.end("Logo not found");return}if(p.method==="GET"&&L==="/api/inventory"){let y;if(P.existsSync(n)){let $=P.readFileSync(n,"utf8");y=cn($).instanceId}if(P.existsSync(t))try{let $=JSON.parse(P.readFileSync(t,"utf8"));$.instanceId&&(y=$.instanceId)}catch{}let A=[...ke],{config:x}=ge({projectRoot:e,surveyTypes:A,instanceId:y});g.writeHead(200,{"Content-Type":"application/json"}),g.end(JSON.stringify({surveyTypes:A,instanceId:y,previewUrl:s,initialConfig:x,previewManifest:Object.fromEntries(Object.keys(c).map($=>[$,`${S}/previews/${$}/index.html`]))}));return}if(p.method==="GET"&&C==="/api/preview-url"){let y=await an(s);g.writeHead(200,{"Content-Type":"application/json"}),g.end(JSON.stringify({url:s,connected:y}));return}if(p.method==="POST"&&C.split("?")[0]==="/api/wizard-quit"){io(e),g.writeHead(200,{"Content-Type":"application/json"}),g.end(JSON.stringify({ok:!0,deleted:"out/previews"})),setTimeout(()=>{k.close(()=>{F(new Error("Client quit the wizard without saving. Local preview garbage collection complete (out/previews removed)."))})},300);return}if(p.method==="POST"&&C==="/api/upload-logo"){let y=await Xo(p),A=JSON.parse(y);P.existsSync(o)||P.mkdirSync(o,{recursive:!0});let x=A.base64.replace(/^data:image\/\w+;base64,/,""),$=Buffer.from(x,"base64"),V=_.extname(A.filename),J=_.basename(A.filename,V).toLowerCase().replace(/[^a-z0-9_-]/g,""),le=`logo_${Date.now()}_${J}${V||".png"}`;P.writeFileSync(_.join(o,le),$),g.writeHead(200,{"Content-Type":"application/json"}),g.end(JSON.stringify({fileName:le}));return}if(p.method==="POST"&&C==="/api/save-config"){let y=await Xo(p),A=JSON.parse(y);A.configuredAt=new Date().toISOString();let x=A.global?.logo;x?.url?.startsWith("data:")&&(x.url=null),P.writeFileSync(t,JSON.stringify(A,null,2),"utf8"),console.log(`
|
|
138
|
+
${I.green}\u2705 UI configuration saved to ${t}${I.reset}`);try{let{runApplyUiConfig:$}=await Promise.resolve().then(()=>(Ee(),Ae));$({projectRoot:e,configPath:t})}catch($){console.log(`${I.yellow} CSS apply skipped: ${$ instanceof Error?$.message:String($)}${I.reset}`)}io(e),console.log(`${I.dim} Local preview garbage collection complete (out/previews removed)${I.reset}`),g.writeHead(200,{"Content-Type":"application/json"}),g.end(JSON.stringify({ok:!0})),setTimeout(()=>{k.close(()=>T())},500);return}if(p.method==="GET"){let y=C.split("?")[0];if(y==="/"&&(y="/index.html"),y.startsWith("/previews/")&&P.existsSync(d)){let $=y.replace(/^\/previews\//,""),V=_.join(d,$),J=_.normalize(V);if(J.startsWith(d)&&P.existsSync(J)&&P.statSync(J).isFile()){let le=P.readFileSync(J);g.writeHead(200,{"Content-Type":no(J)}),g.end(le);return}}let A=P.existsSync(r),x=A?_.join(r,y):_.join(i,"wizard.html");if(A&&P.existsSync(x)&&P.statSync(x).isFile()){let $=P.readFileSync(x);g.writeHead(200,{"Content-Type":no(x)}),g.end($);return}if(!A&&y==="/index.html"){let $=P.readFileSync(_.join(i,"wizard.html"),"utf8");g.writeHead(200,{"Content-Type":"text/html"}),g.end($);return}}g.writeHead(404,{"Content-Type":"text/plain"}),g.end("Not found")}catch(C){g.writeHead(500,{"Content-Type":"text/plain"}),g.end(`Server error: ${U(C)}`)}});k.listen(m,()=>{let p=S;console.log(`
|
|
139
|
+
${I.bold}${I.cyan}\u{1F3A8} Survey UI Customization Wizard${I.reset}`),console.log(`${I.bold}\u{1F517} Client wizard link \u2014 share this URL only:${I.reset}`),console.log(` ${I.green}${p}${I.reset}`),console.log(`${I.dim} Port ${m} (auto-selected if 4200 was in use)${I.reset}`),console.log(`${I.dim} Live previews: ${I.reset}${Object.keys(c).length} components`),console.log(`${I.dim} Preview target: ${I.reset}${s}`),console.log(`${I.dim} Default wizard \u2014 saves directly to survey-ui-config.json when client clicks Review & Build${I.reset}
|
|
140
|
+
`),sn(p)}),k.on("error",F);let R=()=>{io(e),k.close(()=>process.exit(130))};process.once("SIGINT",R),process.once("SIGTERM",R)})}q();import*as be from"fs";import*as Ko from"path";import*as Yo from"http";import*as Zo from"https";Ce();$e();Re();We();var w=a;function dn(e){let{exec:o}=Ie("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function fn(e){return new Promise(o=>setTimeout(o,e))}async function so(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Zo:Yo).request(i,{method:o.method??"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 un(e,o,t,n){return new Promise((i,r)=>{let s=new URL(e),c=s.protocol==="https:"?Zo:Yo,d={"Content-Type":t,"Content-Length":o.length};n&&(d["X-Wizard-Session"]=n.sessionSecret,d["X-Wizard-Session-Id"]=n.sessionId);let h=c.request(s,{method:"PUT",headers:d},m=>{if((m.statusCode??500)>=400){let S="";m.on("data",T=>S+=T),m.on("end",()=>r(new Error(`PUT failed ${m.statusCode}: ${S}`)));return}m.resume(),i()});h.on("error",r),h.write(o),h.end()})}function pn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function et(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=pn(i);if(!s)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let c=Me(),d=ne(c),h=d.activeConfigPath,m=e.apply?!1:e.review!==!1;console.log(`
|
|
141
|
+
${w.bold}${w.cyan}\u{1F3A8} CFM UI Customization (AWS)${w.reset}
|
|
142
|
+
`),m&&(console.log(`${w.dim} Review mode: seed kept in survey-ui-config.json; final + diff written on complete.${w.reset}`),console.log(`${w.dim} Apply later with: npx cfm-sdk confirm-ui-config${w.reset}
|
|
143
|
+
`));let S=[...G],{outputDir:T,files:F}=await me({projectRoot:c,useTemplatesOnly:e.useTemplatesOnly,surveyTypes:S}),k=F.map(y=>({path:y.path,contentType:y.contentType,sizeBytes:y.sizeBytes})),{config:R,source:p}=ge({projectRoot:c,surveyTypes:S,instanceId:s});R.surveyTypes=S,Ve(p),m&&(be.writeFileSync(d.seedPath,JSON.stringify(R,null,2),"utf8"),be.writeFileSync(h,JSON.stringify(R,null,2),"utf8"),console.log(`${w.dim} Seed snapshot \u2192 survey-ui-config.json (+ .seed.json)${w.reset}`));let g=await so(`${r}/wizard/session/start`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({files:k,surveyTypes:S,initialConfig:R})});console.log(`${w.dim} Uploading ${k.length} preview files\u2026${w.reset}`);for(let y of g.uploads){let A=Ko.join(T,y.path),x=be.readFileSync(A),$=k.find(V=>V.path===y.path)?.contentType??"application/octet-stream";await un(y.uploadUrl,x,$,{sessionId:g.sessionId,sessionSecret:g.sessionSecret})}if(await so(`${r}/wizard/previews/upload/complete`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:g.sessionId})}),console.log(`${w.green}\u2705 Previews uploaded${w.reset}`),console.log(`${w.dim} ${k.length} component preview page(s) \u2192 EC2 local server (disk)${w.reset}`),console.log(`
|
|
144
|
+
${w.bold}${w.cyan}\u{1F517} Client wizard link \u2014 share with the client:${w.reset}`),console.log(`${w.green} ${g.wizardUrl}${w.reset}`),console.log(`${w.dim} (Deployed on EC2 \u2014 client customizes here; agent keeps CLI open until submit)${w.reset}
|
|
145
|
+
`),dn(g.wizardUrl),!o){console.log(`${w.yellow}--no-wait: wizard URL (not polling):${w.reset}`),console.log(g.wizardUrl),m&&console.log(`${w.dim} When wizard completes, poll manually or re-run without --no-wait to capture final + diff.${w.reset}`);return}let C=Date.now()+n,L=0;for(;Date.now()<C;){L+=1,process.stdout.write(`\r${w.dim}Waiting for client to finish wizard\u2026 (poll ${L})${w.reset}`);let y=await so(`${r}/wizard/config/${encodeURIComponent(s)}?sessionId=${g.sessionId}`,{headers:{Authorization:`Bearer ${i}`}});if(y.status==="abandoned")throw console.log(`
|
|
146
|
+
${w.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${w.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(y.status==="ready"&&y.config){let A=qe(y)??y.config;if(console.log(`
|
|
147
|
+
${w.green}\u2705 Configuration ready${w.reset}`),y.logoUrl&&console.log(`${w.dim} Logo URL: ${y.logoUrl}${w.reset}`),m){let V=ze(c,R,A);console.log(`${w.green} Seed (unchanged active): ${h}${w.reset}`),console.log(`${w.green} Final: ${d.finalPath}${w.reset}`),console.log(`${w.green} Diff: ${d.diffMdPath}${w.reset}`),console.log(`${w.yellow} ${V.changed.length} changed, ${V.added.length} added, ${V.removed.length} removed${w.reset}`);let J=A.global?.logo;if(J?.fileName)try{await ae({projectRoot:c,fileName:J.fileName,logoUrl:y.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${w.green} Logo saved to public/${J.fileName}${w.reset}`)}catch(le){console.warn(`${w.yellow} Logo download deferred: ${U(le)}${w.reset}`)}console.log(`${w.dim} Apply when ready: npx cfm-sdk confirm-ui-config (promotes JSON + regenerates survey-theme.css)${w.reset}`);return}be.writeFileSync(h,JSON.stringify(A,null,2),"utf8"),console.log(`${w.green} Written ${h}${w.reset}`);let{runApplyUiConfig:x}=await Promise.resolve().then(()=>(Ee(),Ae));x({projectRoot:c,configPath:h});let $=A.global?.logo;$?.fileName&&(await ae({projectRoot:c,fileName:$.fileName,logoUrl:y.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${w.green} Logo saved to public/${$.fileName}${w.reset}`));return}await fn(t)}throw new Error("Timed out waiting for wizard completion")}$e();q();var D=a,ie=process.argv.slice(2),Z=ie[0];async function Cn(){if(Z==="customize"||Z==="init"){Z==="init"&&console.log(`${D.yellow}\u26A0 cfm-sdk init is deprecated. Use \`cfm-sdk customize\` instead.${D.reset}
|
|
148
|
+
`);try{await Vo()}catch(e){console.error(`
|
|
149
|
+
${D.red}\u274C Error: ${U(e)}${D.reset}`),process.exit(1)}}else if(Z==="customize-ui"){let e=ie.includes("--use-templates-only"),o=ie.includes("--no-wait"),t=ie.includes("--apply"),n=ie.includes("--no-review")?!1:!t;try{await et({useTemplatesOnly:e,wait:!o,review:n,apply:t})}catch(i){console.error(`
|
|
150
|
+
${D.red}\u274C Error: ${U(i)}${D.reset}`),process.exit(1)}}else if(Z==="confirm-ui-config"){let e=ie.includes("--diff-only");try{let{runConfirmUiConfig:o}=await Promise.resolve().then(()=>(tt(),ot));await o({diffOnly:e})}catch(o){console.error(`
|
|
151
|
+
${D.red}\u274C Error: ${U(o)}${D.reset}`),process.exit(1)}}else if(Z==="apply-ui-config")try{let{runApplyUiConfig:e}=await Promise.resolve().then(()=>(Ee(),Ae));e({})}catch(e){console.error(`
|
|
152
|
+
${D.red}\u274C Error: ${U(e)}${D.reset}`),process.exit(1)}else if(Z==="fetch-ui-config"){let o=ie.find(t=>t.startsWith("--session="))?.split("=")[1];try{let{runFetchUiConfig:t}=await Promise.resolve().then(()=>(it(),nt));await t({sessionId:o})}catch(t){console.error(`
|
|
153
|
+
${D.red}\u274C Error: ${U(t)}${D.reset}`),process.exit(1)}}else if(Z==="export-previews"){let e=ie.includes("--use-templates-only");try{await me({useTemplatesOnly:e})}catch(o){console.error(`
|
|
154
|
+
${D.red}\u274C Error: ${U(o)}${D.reset}`),process.exit(1)}}else if(Z==="resolve-ui-config"){let e=ie.includes("--write");try{if(e){let o=Je();console.log(`${D.green}\u2705 Wrote ${o}${D.reset}`)}else{let{resolveInitialConfig:o}=await Promise.resolve().then(()=>($e(),ko)),{config:t,source:n}=o({surveyTypes:[]});console.log(JSON.stringify({source:n,config:t},null,2))}}catch(o){console.error(`
|
|
155
|
+
${D.red}\u274C Error: ${U(o)}${D.reset}`),process.exit(1)}}else if(Z==="deploy")try{await po()}catch(e){console.error(`
|
|
156
|
+
${D.red}\u274C Error: ${U(e)}${D.reset}`),process.exit(1)}else console.log(`
|
|
157
|
+
${D.bold}${D.cyan}CFM SDK CLI Tool${D.reset}`),console.log(`
|
|
158
158
|
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)}Cn();
|