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